Java tutorial
//package com.java2s; import java.io.FileWriter; import java.io.IOException; public class Main { /** * Writes the given string into the given file. * * @param contents * String representing the file contents. * @param filename * Name of the file to be written. * @throws IOException */ public static void writeFile(String contents, String filename) throws IOException { FileWriter fw = new FileWriter(filename); fw.write(contents); fw.flush(); fw.close(); } }