-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileRArchiever.java
More file actions
30 lines (26 loc) · 948 Bytes
/
FileRArchiever.java
File metadata and controls
30 lines (26 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.io.*;
public class FileRArchiever {
public void decompressData(FileInputStream istream, FileOutputStream ostream)throws IOException
{
try(BufferedInputStream bfs = new BufferedInputStream(istream);
BufferedOutputStream bws = new BufferedOutputStream(ostream)) {
int symbol,number = 0;
long countSymbols = 0;
symbol = bfs.read();
while(true)
{
while((number = bfs.read()) != -1 && number <= 9 )
countSymbols = countSymbols * 10 + number;
//write temp result
for(int i = 0;i < countSymbols;++i)
bws.write(symbol);
//update
symbol = number;
countSymbols = 0;
//condition exit
if(number <= 9)
break;
}
}
}
}