There are some simple ways, like -:
File file = new File("filename.txt" );
PrintWriter pw = new PrintWriter( file );
pw.write( "The world I'm coming" );
pw.close();
String write = "Hello World!";
FileWriter fw = new FileWriter( file );
BufferedWriter bw = new BufferedWriter( fw );
fw.write( write );
fw.close();