Write string to a file in java

From MyWiki
Revision as of 10:31, 24 February 2016 by George2 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
/*****************************************************************/
/* Copyright 2013 Code Strategies                                */
/* This code may be freely used and distributed in any project.  */
/* However, please do not remove this credit if you publish this */
/* code in paper or electronic form, such as on a web site.      */
/*****************************************************************/
 
package test;
 
import java.io.File;
import java.io.IOException;
 
import org.apache.commons.io.FileUtils;
 
public class WriteStringToFile {
 
	public static void main(String[] args) throws IOException {
		String string = "This is\na test";
		File file = new File("test.txt");
		FileUtils.writeStringToFile(file, string);
	}
}