我想问一下,我们可以结合 BWT MTF 和 Huffman 算法在 java 中获得更高的压缩率吗?过程是什么?MTF 文件写入错误?
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;
}