Java implementation code conversion file

The GBK encoded text file, converted to UTF-8 encoded text file.

package com.fgy.demo;

import java.io. * ;

public class Demo05Test {
    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(new FileInputStream("d:\\GBK.txt"), "gbk");
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("d:\\UTF-8.txt"), "utf-8");
        int len = 0;
        char[] chars = new char[1024];
        while ((len = isr.read(chars)) != -1) {
            osw.write (chariots, 0 , flaxseed);
        }
        osw.close ();
        isr.close();
    }
}

Guess you like

Origin www.cnblogs.com/roadlandscape/p/12168722.html