Convert Shift_JIS format to UTF-8 format

前端 未结 3 1007
粉色の甜心
粉色の甜心 2021-01-07 15:01

I am trying to convert a Shift_JIS formatted file into UTF-8 format. For this, below is my approach:

  1. Read Shift_JIS file
  2. getBytes of each line and con
3条回答
  •  渐次进展
    2021-01-07 15:37

    If you want to copy inFile (SHift_JIS) to outFile (UTF-8).

    try (Reader reader = new InputStreamReader(new FileInputStream(inFile), "Shift_JIS");
        Writer writer = new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8")) {
        char[] buffer = new char[4096];
        int size;
        while ((size = reader.read(buffer)) >= 0)
            writer.write(buffer, 0, size);
    }
    

提交回复
热议问题