Write text file
import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.Writer; public class Main { public static void main(String[] args) throws Exception { Writer writer = null; String text = "This is a text file"; File file = new File("write.txt"); writer = new BufferedWriter(new FileWriter(file)); writer.write(text); writer.close(); } }