Example of PrintWriter

package fileionavigationexample;
import java.io.*;
public class PrintWriterExample {
public static void main(String[] args){
File file = new File(“C:\Users\KUNDAN\Documents\AdvanceJavaNotes.txt”);
try{
FileWriter fw = new FileWriter(file);
PrintWriter pw = new PrintWriter(fw);
pw.println(“Advance Java Is also Termed As Enterprise Edition ie. J2EE.”);
pw.println(“It includes Folowing Topics.”);
pw.println(“1) JDBC:Java Database Conectivity.”);
pw.println(“2) Servelet”);
pw.println(“3) JSP”);
pw.println(“4) Hibernate”);
pw.println(“5) Spring”);
pw.println(“6) Struts”);

pw.close();
fw.close();
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
String f = br.readLine();
while((f = br.readLine()) != null){
System.out.println(f);
}
br.close();
}catch(IOException ex){
ex.printStackTrace();
}
}
}

Leave a Reply