编码转换

mac2022-06-30  29

package com.itcast;import java.io.*;/** * @author newcityman * @date 2019/7/28 - 22:16 * 练习:转换文件编码 * 将GBK编码的文本文件,转换成UTF-8编码的文件 */public class demo06Test {public static void main(String[] args) throws IOException { InputStreamReader isr = new InputStreamReader(new FileInputStream("day18_IOAndProperties\\我是GBK格式的文件.txt"),"gbk"); OutputStreamWriter osr = new OutputStreamWriter(new FileOutputStream("day18_IOAndProperties\\我是UTF_8格式的文件.txt"),"utf-8"); int len; while((len=isr.read())!=-1){ osr.write(len); } osr.close(); isr.close(); }}

转载于:https://www.cnblogs.com/newcityboy/p/11261244.html

相关资源:文本文件编码转换工具 gbk utf8 gb2312
最新回复(0)