Skip to main content

Posts

Showing posts from March 19, 2017

how to write text file using java

welcome java file handling tutorial . in this tutorial we are going to wrie text file using  java here i have used Filewirter to write . use following steps to read text file using java  program 1. create one folder on d drive as f that is name of folder is f 2. create demo.txt file to write on it using program 3. create java program use following code or follow steps from video save java program in same folder import java.io.* package properly in java program 4. compile program and run 5. to understand program read what is FileReader read program explanation given below. // Program by Prakash Sonar import java.io.*; class jWrite { public static void main(String s[]) { try{ FileWriter w=new FileWriter("demo.txt",true); w.write("welcome to Prakash Programming Tutorial"); w.write("\n "); w.write("Thanks for Watching"); w.close(); } catch(Exception e){} } ...

java program to read file line by line

lets learn how to write java  program to read file line by line code is given below follow the steps from video import java.io.*; // program by Prakash Sonar class JfReadLine {   public static void main(String s[])   {     try {  FileReader r=new FileReader("t2.txt");  BufferedReader br=new BufferedReader(r);  String line;  while((line=br.readLine())!=null)  {  System.out.println(line);  } r.close(); } catch( Exception e) { }   } }

java read file Character by Character

welcome java file handling tutorial . in this tutorial we are going to learn how to read text file using  java here i have used FileReader to  read file Character by Character. use following steps to read text file using java  program 1. create one folder on d drive as f that is name of folder is f 2. create t1.txt file write some text on it 3. create java program use following code or follow steps from video save java program in same folder import java.io.* package properly in java program 4. compile program and run 5. to understand program read what is FileReader read program explanation given below. save RfileCh.java // program by Prakash import java.io.*; class RfileCh {  public static void main(String s[])  {   try{        FileReader r=new FileReader("t1.txt");   // used to open a file   int ch;     while((ch=r.read())!=-1)   // here -1 is end of ...

Labels

Show more