public static void write(String path,String content){ File file = delFile(path); FileOutputStream out = null; try { out=new FileOutputStream(file,true); out.write(content.getBytes("utf-8")); } catch (Exception e) { e.printStackTrace(); }finally{ try { out.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } /** * 删除原文件,创建新的文件
* path 路径和文件名称 * */ public static File delFile(String path){ File file=new File(path); try { if(file.exists()&&file.isFile()){ file.delete(); file.createNewFile(); }else{ file.createNewFile(); } } catch (IOException e) { e.printStackTrace(); } return file; }