Read data from file in java


Write a program to read data from file.

Write a java code to read data from file.

Read data from file using java code.

Write a program to read data from file using java code.

//Read data from file

import java.io.*;

public class readdatafromfile {

 public static void main(String args[]){

        try{

            //readfile from same content

            FileInputStream f=new FileInputStream("rajendrafile.txt");

          // enter the data in the created file

            System.out.println("See the content of file:");

            int c;

            while((c=f.read()) != -1)

            { System.out.print((char)c);}     

            f.close(); //close the file         

        }catch(IOException e){ }

    }

}

No comments:

Post a Comment