PrintStream Println() Example
Terminates the current line by writing the line separator string.
PrintStreamclass Println() method example. This example shows you how to use Println() method.This method Terminates the current line by writing the line separator string.
Here is the code:-
/**
* @Program that Terminates the current line by writing the line separator string.
* Println.java
* Author:-RoseIndia Team
* Date:-10-Jun-2008
*/
import java.io.*;
public class Println {
public static void main(String[] args) throws IOException {
String d = "Girish";
//Creating FileOutputStream object
FileOutputStream out = new FileOutputStream("text.txt");
FileInputStream fin = new FileInputStream("text.txt");
//Creating PrintStream object
PrintStream ps = new PrintStream(out);
//Terminates the current line by writing the line separator string.
ps.println(d);
System.out.print("String is : ");
for(int i=0;i<d.length();i++)
System.out.print((char) fin.read());
}
} |
|