登 录
/** * @param path文件地址 * @param append是否追加 * @param value写入值 * @param charsetName字符集名称eg:[gb2312] * @throws IOException */ public static void writerLine(String path,boolean append,String value,String charsetName) throws IOException { OutputStreamWriter osw=null; BufferedWriter bw=null; try { osw=new OutputStreamWriter(new FileOutputStream(path,append),charsetName); bw=new BufferedWriter(osw); bw.write(new Date().toLocaleString()+value); bw.newLine(); bw.flush(); } catch (UnsupportedEncodingException e) { System.out.println("没有指定的字符集"); e.printStackTrace(); } catch (FileNotFoundException e) { System.out.println("没有指定的文件"); e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); throw new IOException("IOException"); } finally { bw.close(); osw.close(); } }
抱歉!评论已关闭.