Here you can find the source of writeFile(String contents, String filename)
Parameter | Description |
---|---|
contents | String representing the file contents. |
filename | Name of the file to be written. |
Parameter | Description |
---|---|
IOException | an exception |
public static void writeFile(String contents, String filename) throws IOException
//package com.java2s; import java.io.*; public class Main { /**//from ww w . ja va 2 s .c o m * 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(); } }