import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
class BufferedInputStreamDemo
{
public static void main(String args[]) throws IOException
{
FileInputStream fin = new FileInputStream("text.txt");
BufferedInputStream bin = new BufferedInputStream(fin);
System.out.println("Number of remaining bytes:" + bin.available());
boolean b=bin.markSupported();
if (b)
bin.mark(bin.available());
bin.skip(4);
System.out.println("FileContents :");
// read characters from FileInputStream and
// write them
int ch;
while ((ch=bin.read()) != -1)
System.out.print((char)ch);
// illustrating reset() method
bin.reset();
while ((ch=bin.read()) != -1)
System.out.print((char)ch);
// close the file
fin.close();
}
}
No comments:
Post a Comment