How to Write to file in Java - File Handling in java
Main.java
import java.io.FileNotFoundException; import java.util.Formatter; public class Main { public static void main(String args[]) throws FileNotFoundException{ Formatter formatter = new Formatter("myFile.txt"); formatter.format("THe string I want to write is: %s", "My String"); if (formatter!=null) formatter.close(); } }
No comments:
Post a Comment