you should open the file in append mode for this, by default FileOutputStream opens the file in write mode. And you do not need to check the existence of file , this will be done implicitly by FileOutputStream
private static void write(String Swrite) throws IOException { FileOutputStream fop=new FileOutputStream(file, true); if(Swrite!=null) fop.write(Swrite.getBytes()); fop.flush(); fop.close(); }
source share