Writes the strings into the text file named “output.txt”. If “output.txt” file does not exist, the Java will create it for you.
package javaapplication1; import java.io.*; public class JavaApplication1 { public static void main(String args[]) { FileWriter fw = null; PrintWriter pw = null; try{ fw = new FileWriter("output.txt"); pw = new PrintWriter(fw); String s1 = "This IS new Program"; pw.println(s1); pw.flush(); } catch(IOException ieox){ System.out.println(ieox); } } }
Comments
Post a Comment