CharArrayReader In Java Example

Chapter: Java I/O Last Updated: 21-07-2016 17:51:37 UTC

Program:

            /* ............... START ............... */
                
import java.io.CharArrayReader;

public class JavaCharArrayReader {
	public static void main(String[] args) {

		try {
			char c[] = { 'J', 'A', 'V', 'A', 'S', 'C', 'A', 'N' };
			CharArrayReader charReader = new CharArrayReader(c);

			int i;
			while ((i = charReader.read()) != -1) {
				System.out.print((char) i);
			}

		} catch (Exception ex) {
			System.out.println(ex.getMessage());
		}
	}
}
                /* ............... END ............... */
        

Output

JAVASCAN

Notes:

  • The java.io.CharArrayReader.read() method reads a single character. If the stream ends, it returns -1.
  • CharArrayReader is an implementation of an input stream that uses a character array as the source. This class has two constructors, each of which requires a character array to provide the data source.

Tags

CharArrayReader, Java, Java I/O

Similar Programs Chapter Last Updated
Hidden File Check In Java Example Java I/O 20-06-2016
FileWriter In Java Example Java I/O 21-07-2016
FileReader In Java Example Java I/O 21-07-2016
FileOutputStream In Java Example Java I/O 21-07-2016
FileInputStream In Java Example Java I/O 21-07-2016
DataOutputStream In Java Example Java I/O 21-07-2016
DataInputStream In Java Example Java I/O 21-07-2016
CharArrayWriter In Java Example Java I/O 13-04-2016
ByteArrayOutputStream In Java Example Java I/O 21-07-2016
ByteArrayInputStream In Java Example Java I/O 21-07-2016
BufferedWriter In Java Example Java I/O 21-07-2016
BufferedReader In Java Example Java I/O 21-07-2016
BufferedOutputStream In Java Example Java I/O 21-07-2016
BufferedInputStream In Java Example Java I/O 21-07-2016
ProcessBuilder To Make System Calls In Java Java I/O 19-08-2017

1