Java以utf8保存为文本文件

FileOutputStream fos = null;
  OutputStreamWriter writer = null;
  try {
   File file = new File(filepath);
   fos = new FileOutputStream(file);
   writer = new OutputStreamWriter(fos,"utf-8");
   writer.write(makeLanguageRes(resource));
  } catch (Exception e) {
   CheckXmlUtil.addErrorMsg(CheckXmlUtil.TEXT_FOMART_ERROR,
     CheckXmlUtil.SAVE_XML_FIALL, e);
   return null;
  } finally {
   try {
    if(fos != null){
     fos.close();     
    }
   } catch (IOException e1) {
    CheckXmlUtil.addErrorMsg(CheckXmlUtil.TEXT_FOMART_ERROR,
      CheckXmlUtil.SAVE_XML_FIALL, e1);
   }
   if (writer != null) {
    try {
     writer.close();
    } catch (IOException e) {

     CheckXmlUtil.addErrorMsg(CheckXmlUtil.TEXT_FOMART_ERROR,
       CheckXmlUtil.SAVE_XML_FIALL, e);
    }
   }

  }


ori path: http://blog.csdn.net/songj_ntyrs/article/details/8364397

发布了430 篇原创文章 · 获赞 415 · 访问量 925万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览