classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] [generics] Patch: FYI: PrintStream fix


From: Tom Tromey
Subject: [cp-patches] [generics] Patch: FYI: PrintStream fix
Date: 02 Jan 2005 15:39:26 -0700

I'm checking this in on the generics branch.

This adds a few missing thing to PrintStream.

Tom

Index: ChangeLog
from  Tom Tromey  <address@hidden>
        * java/io/PrintStream.java: Implement Appendable.
        (PrintStream(String)): New constructor.
        (PrintStream(String,String)): Likewise.
        (PrintStream(File)): New constructor.
        (PrintStream(File,String)): Likewise.
        (append): New methods.

Index: java/io/PrintStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/PrintStream.java,v
retrieving revision 1.19
diff -u -r1.19 PrintStream.java
--- java/io/PrintStream.java 10 Aug 2003 03:04:38 -0000 1.19
+++ java/io/PrintStream.java 2 Jan 2005 22:42:14 -0000
@@ -1,5 +1,5 @@
 /* PrintStream.java -- OutputStream for printing output
-   Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2001, 2003, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -56,7 +56,7 @@
  * @author Aaron M. Renn <address@hidden>
  * @author Tom Tromey <address@hidden>
  */
-public class PrintStream extends FilterOutputStream
+public class PrintStream extends FilterOutputStream implements Appendable
 {
   /**
    * This boolean indicates whether or not an error has ever occurred
@@ -136,6 +136,40 @@
     this.auto_flush = auto_flush;
   }
 
+  /** @since 1.5 */
+  public PrintStream (String filename) throws FileNotFoundException
+  {
+    super (new FileOutputStream (filename));
+    pw = new PrintWriter (new OutputStreamWriter (out), false);
+    auto_flush = false;
+  }
+
+  /** @since 1.5 */
+  public PrintStream (String filename, String encoding)
+    throws FileNotFoundException
+  {
+    super (new FileOutputStream (filename));
+    pw = new PrintWriter (new OutputStreamWriter (out, encoding), false);
+    auto_flush = false;
+  }
+
+  /** @since 1.5 */
+  public PrintStream (File file) throws FileNotFoundException
+  {
+    super (new FileOutputStream (file));
+    pw = new PrintWriter (new OutputStreamWriter (out), false);
+    auto_flush = false;
+  }
+
+  /** @since 1.5 */
+  public PrintStream (File file, String encoding)
+    throws FileNotFoundException
+  {
+    super (new FileOutputStream (file));
+    pw = new PrintWriter (new OutputStreamWriter (out, encoding), false);
+    auto_flush = false;
+  }
+
   /**
    * This method checks to see if an error has occurred on this stream.  Note
    * that once an error has occurred, this method will continue to report
@@ -467,5 +501,27 @@
         setError ();
       }
   }
+
+  /** @since 1.5 */
+  public PrintStream append(char c) throws IOException
+  {
+    print(c);
+    return this;
+  }
+
+  /** @since 1.5 */
+  public PrintStream append(CharSequence cs) throws IOException
+  {
+    print(cs == null ? "null" : cs.toString());
+    return this;
+  }
+
+  /** @since 1.5 */
+  public PrintStream append(CharSequence cs, int start, int end)
+    throws IOException
+  {
+    print(cs == null ? "null" : cs.subSequence(start, end).toString());
+    return this;
+  }
 } // class PrintStream
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]