java字節轉碼,Shift_JIS轉UTF8

public static void read(String path,String path1){
        File file = new File(path);
        File file1 = new File(path1);
        int rownum = 1;
        String row;
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file),"Shift_JIS"));
            BufferedWriter out = new BufferedWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file1),"UTF8")));
            while ((row = in.readLine()) != null) {
                rownum++;
                out.append(row + "\r\n");
            }
            out.close();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章