• [JAVA基础]流文件读写文件编码转换


    将本地的gbk文件流读取变换成utf-8文件

        public static void gbk2utf8(String targetFile,String outFile)
        {
            BufferedReader br = null;
            BufferedWriter bw = null;
            try
            {
                InputStream is = new FileInputStream(targetFile);
                OutputStream os = new FileOutputStream(outFile);
                br = new BufferedReader(new InputStreamReader(is,"gbk"));
                String str = "";
                bw = new BufferedWriter(new OutputStreamWriter(os,"utf-8"));
                while((str = br.readLine())!=null)
                {
                    bw.write(str);
                    bw.newLine();   
                }
            
            } catch (Exception e)
            {
                e.printStackTrace();
            } 
            finally
            {
                try
                {
                
                    if(null!=bw)
                        bw.close();
                    if(null!=br)
                        bw.close();
                } catch (IOException e)
                {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
  • 相关阅读:
    eclipse安装pydev
    pymongo常见的高级用法
    android sdk下载SDK Platform失败记录
    centos7 yum安装redis(转)
    centos7 将服务添加到systemctl
    python Parent.__init()和super(Child, self)的区别
    流畅的python第二十章属性描述符学习记录
    流畅的python第十九章元编程学习记录
    python 协程的学习记录
    [转]Shell脚本之无限循环的两种方法
  • 原文地址:https://www.cnblogs.com/itgmhujia/p/2744463.html
Copyright © 2020-2023  润新知