File file = new File(...); try { FileOutputStream fout = new FileOutputStream(file); PrintWriter pWriter = new PrintWriter(fout); pWriter.println("some text"); pWriter.flush(); pWriter.close(); fout.close(); } catch(IOException re) { }