/*****************************************************************/ /* 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); } }