118 Program to demonstrate BufferedInputStream in Java

Code:
/*
Program to demonstrate BufferedInputStream
*/

import java.io.*;

class BufferedIDemo
{

public static void main(String args[]) throws IOException
{
File file = new File("t1.txt");

FileInputStream fis = new FileInputStream(file);

BufferedInputStream bis = new BufferedInputStream(fis);


byte buffer[] = new byte[1024];

int br = bis.read(buffer);

while(br != -1 )
{
System.out.print(new String(buffer,0,br));

br = bis.read(buffer);
}

}
}

Ouput:

BufferedInputStream in Java

Previous
Next Post »