This article describes the method of Java using utf8 format to save text files. Share it for your reference, as follows:
FileOutputStream fos = null;OutputStreamWriter writer = null;try { File file = new File(filepath); fos = new FileOutputStream(file); writer = new Outpu tStreamWriter(fos,"utf-8"); writer.write(makeLanguageRes(resource ));} catch (Exception e) { CheckXmlUtil.addErrorMsg(CheckXmlUtil.TEXT_FOMART_ERROR, CheckXmlUtil.SAVE_XML_FIALL, e); return null;} finally y { 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); } }}I hope this article will be helpful to everyone's Java programming.