-
Notifications
You must be signed in to change notification settings - Fork 2
/
input_output#4.java
34 lines (32 loc) · 1.06 KB
/
input_output#4.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
// Java program to demonstrate BufferedInputStream methods
class BufferedInputStreamDemo
{
public static void main(String args[]) throws IOException {
FileInputStream fin = new FileInputStream("C:\\Users\\ABHISHEK\\Documents\\NetBeansProjects\\practice\\target\\classes\\practice_java\\test.txt");
BufferedInputStream bin = new BufferedInputStream(fin);
// illustrating available method
System.out.println("Number of remaining bytes:" +
bin.available());
// illustrating markSupported() and mark() method
boolean b=bin.markSupported();
if (b)
bin.mark(bin.available());
// illustrating skip method
/*Original File content:
* This is my first line
* This is my second line*/
bin.skip(4);
System.out.println("FileContents :");
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);
fin.close();
}
}