import java.io.*; public class UTF8Fix{ public static void main(String[] args){ ByteFixer byte_fixer = new ByteFixer("badencoding.txt"); File fout = new File("goodencoding.txt"); BufferedOutputStream writer = null; try { writer = new BufferedOutputStream(new FileOutputStream(fout)); } catch (FileNotFoundException e) { System.err.println("Problem opening writer, file not found"); return; } byte[] character; int count = 0; while(true){ character = byte_fixer.getNextCharacter(); if(character==null) break; try { writer.write(character); count++; } catch (IOException e) { e.printStackTrace(); } if(count%1000==0){ System.out.print("."); System.out.flush(); if(count==40000){ System.out.println(); count=0; } } } try { byte_fixer.close(); writer.close(); } catch (IOException e) { System.err.println("Unable to close reader/writer"); } } }