728x90 AdSpace

Wednesday, 2 October 2013

Read File using BufferedInputStream

In this tutorials we are going to see how to read file using BufferedInputStream.

  1. Create project called JavaMisc.
  2. Create package called com.javatutorialscorner.io 
  3. Create java class called FileReaderExample under com.javatutorialscorner.io package.


package com.javatutorialscorner.io;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class FileReaderExample {

public static void main(String[] args) {

File file = null;
FileInputStream fins = null;
BufferedInputStream bins = null;
DataInputStream din = null;

file = new File("C:\\jtc\\javatutorialscorner.txt");
try {
fins = new FileInputStream(file);
bins = new BufferedInputStream(fins);
din = new DataInputStream(bins);
while (din.available() != 0) {
} catch (IOException e) {
// TODO Auto-generated catch block
} finally {

try {
} catch (IOException e) {
// TODO Auto-generated catch block




Now run the program see the following output in console.

this is test file created by java tutorials corner

This content read from input file

Annamalai Thangaraj

Annamalai is working as Technical Lead in Leading Telecom company with 5+ years experience in Identity and Access Management , Telecom and Networks, BigData, Java, Spring, Struts, Hibernate, AngularJS, and Enterprise Web Application Development.

Website: Java Tutorials Corner

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments


Post a Comment

Item Reviewed: Read File using BufferedInputStream Rating: 5 Reviewed By: Annamalai Thangaraj