PrintStream Flush() Example

Flushes the stream.


PrintStreamclass Flush() method example. This example shows you how to use Flush() method.This method Flushes the stream.

Here is the code:-

/**
 * @Program that Flushes the stream.
 * Flush.java 
 * Author:-RoseIndia Team
 * Date:-10-Jun-2008
 */
import java.io.*;

public class Flush {

    public static void main(String[] argsthrows IOException {
        String c = "Girish Tewari";
        //Creating FileOutputStream object
        FileOutputStream out = new FileOutputStream("/home/girish/Desktop/g/m.txt");
        FileInputStream fin = new FileInputStream("/home/girish/Desktop/g/m.txt");
        //Creating PrintStream object
        PrintStream ps = new PrintStream(out);
        //Appends the specified character sequence to this output stream.
        ps.append(c,7,13);
        System.out.println("Append successfully");
        System.out.print("String after Appending is :");
        for (int i = 0; i < c.length(); i++) {
            System.out.print((charfin.read());
       }
        ps.close();
        //   Flushes the stream.
        ps.flush();
    }
}

Output of the Program
 Append successfully
String after Appending is :Tewari

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US