Reader Read1() Example
Reads characters into an array.
Reader class Read1() method example. This example shows you how to use Read1() method.This method Reads characters into an array.
Here is the code:-
/**
* @Program that Reads characters into an array.
* Read1.java
* Author:-RoseIndia Team
* Date:-5-jun-2008
*/
import java.io.*;
public class Read1 {
public static void main(String[] args)throws IOException {
String s = "RoseIndia";
StringReader reader = new StringReader(s);
char[] newArr = new char[s.length() + 11];
newArr[10] = 'R';
newArr[11] = 'o';
newArr[12] = 'H';
newArr[13] = 'l';
newArr[14] = 'N';
newArr[15] = 'I';
reader.read(newArr);
System.out.print("The new array contains: ");
System.out.println(newArr);
reader.close();
}
} |
Output of the Program
| The new array contains: RoseIndiaROHINI |
|