Tag:res oid Path null new ase += create document    
Create file public static void CreateFile (file filename) {try {if (!filename.exists ()) {Filename.createnewfile ()}} catch (Exception e) {//Todo:handle exceptione.printstacktrace ();}} Write TXT content is not overwritten append write public static Boolean filechasewrite (String content,string filepath) {Boolean flag=false;try { FileWriter fw=new FileWriter (filepath,true); Fw.write (Content); Fw.flush (); Fw.close (); flag=true;} catch (Exception e) {//E.printstacktrace ();} return flag;} Write txt content overwrite original content public static Boolean writetxtfile (String content,string filepath) {Boolean flag=false;try {// The path to the TXT document written PrintWriter pw=new PrintWriter (filepath);//write content Pw.write (contents);p W.flush ();p w.close (); flag=true;} catch (Exception e) {e.printstacktrace ();} return flag;} Read txt content public static String readtxtfile (file file) {string sresult= ""; try {InputStreamReader reader=new InputStreamReader (new FileInputStream (file), "GBK"); BufferedReader br=new BufferedReader (reader); String S=null;while ((S=br.readline ())!=null) {sresult+=s; System.out.println (s);}}catch (Exception e) {e.printstacktrace ();} return sresult;}
Java read txt file and overwrite write TXT file and append write txt