1,将GBK转换为UTF-8

  1. public class Text01 {
  2. public static void main(String[] args) throws IOException {
  3. InputStreamReader isr = new InputStreamReader(new FileInputStream("G:\\xxx\\GBK.txt"),"GBK");
  4. OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("G:\\xxx\\UTF-8.txt"),"UTF-8");
  5. char[] chars = new char[1024 * 8];
  6. int length;
  7. while ((length = isr.read(chars)) != -1){
  8. osw.write(chars,0,length);
  9. }
  10. osw.close();
  11. isr.close();
  12. }
  13. }