
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert Character Array to Reader in Java
The CharArrayReader is a subclass of Reader class and it can implement a character buffer that can be used as a character input stream. The CharArrayReader reads characters from a character array either completely or partially starting from an offset. The important methods of a CharArrayReader class are close(), mark(), read(), skip() and reset().
Syntax
public class CharArrayReader extends Reader
Example
import java.io.*; public class CharArrayReaderTest { public static void main(String args[]) throws Exception { char array[] = { 'T', 'u', 't', 'o', 'r', 'i', 'a', 'l', 's', ' ', 'P', 'o', 'i', 'n', 't', '!'}; CharArrayReader car = new CharArrayReader(array); BufferedReader br = new BufferedReader(car); String line; while ((line = br.readLine()) != null) { System.out.println(line); } }
Output
Tutorials Point!
Advertisements