[Assorted-commits] SF.net SVN: assorted: [270] sandbox/trunk/src/java/Flushing.java
                
                Brought to you by:
                
                    yangzhang
                    
                
            
            
        
        
        
    | 
      
      
      From: <yan...@us...> - 2008-01-22 10:56:07
      
     | 
| Revision: 270
          http://assorted.svn.sourceforge.net/assorted/?rev=270&view=rev
Author:   yangzhang
Date:     2008-01-22 02:55:58 -0800 (Tue, 22 Jan 2008)
Log Message:
-----------
added flushing
Added Paths:
-----------
    sandbox/trunk/src/java/Flushing.java
Added: sandbox/trunk/src/java/Flushing.java
===================================================================
--- sandbox/trunk/src/java/Flushing.java	                        (rev 0)
+++ sandbox/trunk/src/java/Flushing.java	2008-01-22 10:55:58 UTC (rev 270)
@@ -0,0 +1,17 @@
+import java.io.*;
+public class Flushing {
+	public static void main(String[] args) throws Exception {
+		// Try piping stdout to a file.  Notice that as this is running,
+		// everything is flushed.  So it seems autoFlushing is on by default.
+		for (int i = 0; i < 3; i++) {
+			System.out.println("hello, world");
+			Thread.sleep(1000);
+		}
+		// Same with this one, obviously (autoFlush here is on).
+		PrintWriter writer = new PrintWriter(System.out, true);
+		for (int i = 0; i < 3; i++) {
+			writer.println("goodbye, world");
+			Thread.sleep(1000);
+		}
+	}
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |