Hi, i need a like bit of help on understanding how this code actually works.
this program basically encodes files, but can someone tell me what these three methods actually do in short detail?
import java.io.*;
import java.util.*;
public class BWTEncoder
{
private int _blockSize;
private byte _block[];
private BZTableEntry _table[];
private DataOutputStream _oos;
public BWTEncoder(int blockSize, OutputStream out)
{
_blockSize = blockSize;
_block = new byte[_blockSize];
_oos = new DataOutputStream(out);
}
void encodeStream(InputStream input)
{
boolean more;
try
{
do
{
more = processBlock(input);
_oos.flush();
} while(more);
}
catch(IOException e)
{
System.err.println("File Error");
return;
}
}
private boolean processBlock(InputStream f) throws IOException
{
int read, end;
int first, last;
read = f.read(_block,0,_blockSize);
if(read > 0)
{
_table = new BZTableEntry[read];
for(int i = 0; i < read; i++)
{
end = read - 1 - i;
_table[i] = new BZTableEntry(end, read, _block);
}
Arrays.sort(_table, new BZTableEntryComparator());
_oos.writeInt(read);
first = last =0;
for(int i = 0; i < read; i++)
{
if(_table[i].startPoint() == 0)
{
last = i;
}
}
_oos.writeInt(last);
for(int i = 0; i < read; i++)
{
_oos.write(_table[i].getAt(read-1));
}
}
return (read == _block.length);
}
}
thanks