PrintStream Println3() Example
Prints an array of characters and then terminate the line.
PrintStreamclass Println3() method example. This example shows you how to use Println3() method.This method Prints an array of characters and then terminate the line.
Here is the code:-
/**
* @Program that Prints an array of characters and then terminate the line.
* Println3.java
* Author:-RoseIndia Team
* Date:-10-Jun-2008
*/
import java.io.*;
public class Println3{
public static void main(String[] args) throws IOException {
char d[] = {'G','i','r','i','s','h'};
//Creating FileOutputStream object
FileOutputStream out = new FileOutputStream("text.txt");
FileInputStream fin = new FileInputStream("text.txt");
//Creating PrintStream object
PrintStream ps = new PrintStream(out);
//Prints an array of characters and then terminate the line.
ps.println(d);
System.out.print("Array of characters is : ");
for(int i=0;i<d.length;i++)
System.out.print((char) fin.read());
}
} |
Output of the Program
| Array of characters is : Girish |
|