java中gbk转utf-8
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(); } }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。