Java應用utf8格局保留文本文件的辦法。本站提示廣大學習愛好者:(Java應用utf8格局保留文本文件的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是Java應用utf8格局保留文本文件的辦法正文
本文實例講述了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); } } }
願望本文所述對年夜家java法式設計有所贊助。