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