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();
        }
    }

 

你可能感兴趣的:(java)