import
java.io.*;
public
class
NewClass
{
public
static
void
main(String[] args)
throws
IOException
{
String str1 =
"Hello Geeks"
;
String str2 =
"GeeksForGeeks"
;
StringBufferInputStream Geek_buffer1 =
new
StringBufferInputStream(str1);
StringBufferInputStream Geek_buffer2 =
new
StringBufferInputStream(str2);
System.out.println(
"Use of available() 1 : "
+ Geek_buffer1.available());
int
a =
0
;
System.out.print(
"Use of read() method : "
);
while
((a = Geek_buffer1.read()) != -
1
)
{
char
c1 = (
char
)a;
System.out.println(c1);
long
char_no = Geek_buffer1.skip(
1
);
System.out.println(
"Characters Skipped : "
+ (c1+
1
));
}
System.out.println(
""
);
System.out.println(
"Use of available() 2 : "
+ Geek_buffer2.available());
byte
[] buffer =
new
byte
[
15
];
Geek_buffer2.read(buffer,
1
,
2
);
int
b =
0
;
System.out.print(
"read(char[] char_array, int offset, int maxlen): "
);
while
((b = Geek_buffer2.read()) != -
1
)
{
char
c2 = (
char
)b;
System.out.print(c2);
}
System.out.println(
""
);
Geek_buffer1.reset();
int
i =
0
;
System.out.print(
"\nUse of read() method again after reset() : "
);
while
((i = Geek_buffer1.read()) != -
1
)
{
char
c3 = (
char
)i;
System.out.print(c3);
}
}
}