I want to ask that can we combine the BWT MTF and Huffman Algorithms to get higher compression rate in java? what will be the process? Error In Wriring of MTF file?
public class MTF{
static File f=new File("MTF.txt");
public static File encode(String msg, String symTable)throws Exception{
if(!f.exists())
f.createNewFile();
StringBuilder s = new StringBuilder(symTable);
for(char c : msg.toCharArray()){
int idx = s.indexOf("" + c);
FileWriter writer = new FileWriter(f);
writer.write(idx+" ");
System.out.print(idx+" ");
writer.flush();
writer.close();
s = s.deleteCharAt(idx).insert(0, c);
}
System.out.println("MTF done");
return f;
}
It is quite easy to test this hypothesis, the process would be:
In general: Applying MTF should improve compresability, as, for example mentioned here: http://michael.dipperstein.com/bwt/