Subscribe to Get Free Material Updates!
Visit my new blog WebData Scraping - Web Scraping Service provider company in India.

Read File Using InputStream


/* Read A String (Byte Array) From File using FileInputStream*/

import java.io.*;


class InputStreamDemo1
{
  
 public static void main(String[] args)
 {
  
  try
  {
  File f1=new File("MyFile.txt");
  FileInputStream fin=new FileInputStream(f1);
  DataInputStream din=new DataInputStream(fin);
  byte[] byte_arr=new byte[100];
  
   while(din.available()!=0)
   {
   
    System.out.println(din.readLine());
   }
  }

  catch(Exception e)
  {
   System.out.println(e);
  }

 }
}

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes