Advertisement
CharacterArrayReader(char[] buf) |
---|
This constructor is most used and it creates a CharacterArrayReader object with its own buffer initialized to the value of a char array buf
Example-:
|
Methods | Description |
---|---|
available() | This method gives the remaining number of bytes available to read from this character input stream's buffer. |
read() | This method reads one character at a time from this character input stream's buffer. |
read(char[]) | This method reads a whole character array at a time from this character input stream's buffer. |
close() | This method closes this input stream and also frees any resources connected with this character input stream. |
Advertisement
//Program to use a character buffer that can be used as character input stream
import java.io.*;
class A
{
public static void main(String... ar)
{
char[] arr= new char[]{'a','b','c','d','e','f'};
CharArrayReader car= new CharArrayReader(arr); // an internet character buffer is created,
//big enough to hold a character array
int c;
try
{
while( (c= car.read())!=-1) //buffer is read one character a time
System.out.print((char)c);
}
catch(IOException e)
{
System.out.println(e);
}
}
}
abcde
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement