public class GbkToUtf8 { public static void main(String[] args) throws IOException { File filein = new File("G:/test.txt"); File fileout = new File("G:/result1.txt"); BufferedReader br = new BufferedReader(new FileReader(filein)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileout, true), "utf-8")); String line = null; StringBuilder content = new StringBuilder(); while((line = br.readLine())!=null){ String iso = new String(line.getBytes("utf-8"),"iso-8859-1"); String utf8 = new String(iso.getBytes("iso-8859-1"),"utf-8"); content.append(utf8); } bw.write(content.toString()); br.close(); bw.close(); } }
时间: 2024-10-11 18:59:15