Sunday, 15 May 2016

Reading a file using FileInputStream in java

import java.io.FileInputStream;

public class ReadFile {
   
   
   
    public static void main(String args[])
        
           
    {  FileInputStream fin ;
    try{
  
    fin= new FileInputStream("C:\\Users\\user\\Desktop\\ash.txt");
    int c;
    while((c=fin.read())!=-1)
    {
       
       
        System.out.print((char)c);
    }
   
    }
    catch(Exception e){}
   
    } 
   
}

No comments:

Post a Comment