diff -ru CVS/classpath/java/io/PrintStream.java updated/classpath/java/io/PrintStream.java
--- CVS/classpath/java/io/PrintStream.java	2010-06-18 16:04:04.000000000 +0400
+++ updated/classpath/java/io/PrintStream.java	2010-06-18 16:06:52.000000000 +0400
@@ -1,5 +1,5 @@
 /* PrintStream.java -- OutputStream for printing output
-   Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005, 2006
+   Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005, 2006, 2010
    Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
@@ -70,7 +70,7 @@
    * from the other, and we want to maximize performance. */
 
   // Line separator string.
-  private static final char[] line_separator
+  private final char[] line_separator
     = SystemProperties.getProperty("line.separator", "\n").toCharArray();
 
   /**
@@ -136,7 +136,7 @@
   public PrintStream (String fileName)
     throws FileNotFoundException
   {
-    this (new FileOutputStream(new File(fileName)), false);
+    this (new FileOutputStream(fileName), false);
   }
 
   /**
@@ -155,7 +155,7 @@
   public PrintStream (String fileName, String encoding)
       throws FileNotFoundException,UnsupportedEncodingException
   {
-    this (new FileOutputStream(new File(fileName)), false, encoding);
+    this (new FileOutputStream(fileName), false, encoding);
   }
 
   /**
@@ -181,10 +181,14 @@
    * @param out The <code>OutputStream</code> to write to.
    * @param auto_flush <code>true</code> to flush the stream after every
    * line, <code>false</code> otherwise
+   * @throws NullPointerException if <code>out</code> is <code>null</code>
    */
   public PrintStream (OutputStream out, boolean auto_flush)
   {
     super (out);
+    if (out == null)
+      throw new NullPointerException();
+
     String encoding;
     try {
         encoding = SystemProperties.getProperty("file.encoding");
@@ -213,11 +217,14 @@
    * line, <code>false</code> otherwise
    * @param encoding The name of the character encoding to use for this
    * object.
+   * @throws NullPointerException if <code>out</code> is <code>null</code>
    */
   public PrintStream (OutputStream out, boolean auto_flush, String encoding)
     throws UnsupportedEncodingException
   {
     super (out);
+    if (out == null)
+      throw new NullPointerException();
 
     new String(new byte[]{0}, encoding);    // check if encoding is supported
     this.encoding = encoding;
@@ -292,11 +299,12 @@
   {
     try
       {
-        writeChars(str, 0, str.length());
+        writeChars(str);
         if (println)
-          writeChars(line_separator, 0, line_separator.length);
-        if (auto_flush)
-          flush();
+          writeChars(line_separator);
+        if (auto_flush
+            && (println || str.lastIndexOf ('\n') >= 0))
+          out.flush();
       }
     catch (InterruptedIOException iioe)
       {
@@ -308,16 +316,17 @@
       }
   }
 
-  private synchronized void print (char[] chars, int pos, int len,
-                                   boolean println)
+  private synchronized void print (char[] chars, boolean println)
   {
     try
       {
-        writeChars(chars, pos, len);
+        writeChars(chars);
         if (println)
-          writeChars(line_separator, 0, line_separator.length);
-        if (auto_flush)
-          flush();
+          writeChars(line_separator);
+        if (auto_flush
+            && (println || chars == line_separator
+                || lastIndexOfNewLine(chars) >= 0))
+          out.flush();
       }
     catch (InterruptedIOException iioe)
       {
@@ -329,17 +338,26 @@
       }
   }
 
-  private void writeChars(char[] buf, int offset, int count)
+  // Equivalent to: new String(chars).lastIndexOf('\n')
+  private static int lastIndexOfNewLine (char[] chars)
+  {
+    int i = chars.length;
+    while (i-- > 0)
+      if (chars[i] == '\n')
+        break;
+    return i;
+  }
+
+  private void writeChars(char[] buf)
     throws IOException
   {
-      byte[] bytes = (new String(buf, offset, count)).getBytes(encoding);
-      out.write(bytes, 0, bytes.length);
+      writeChars(new String(buf));
   }
 
-  private void writeChars(String str, int offset, int count)
+  private void writeChars(String str)
     throws IOException
   {
-      byte[] bytes = str.substring(offset, offset+count).getBytes(encoding);
+      byte[] bytes = str.getBytes(encoding);
       out.write(bytes, 0, bytes.length);
   }
 
@@ -428,9 +446,9 @@
    *
    * @param ch The <code>char</code> value to be printed
    */
-  public synchronized void print (char ch)
+  public void print (char ch)
   {
-    print(new char[]{ch}, 0, 1, false);
+    print(new char[] { ch }, false);
   }
 
   /**
@@ -441,7 +459,7 @@
    */
   public void print (char[] charArray)
   {
-    print(charArray, 0, charArray.length, false);
+    print(charArray, false);
   }
 
   /**
@@ -451,7 +469,7 @@
    */
   public void println ()
   {
-    print(line_separator, 0, line_separator.length, false);
+    print(line_separator, false);
   }
 
   /**
@@ -555,9 +573,9 @@
    *
    * @param ch The <code>char</code> value to be printed
    */
-  public synchronized void println (char ch)
+  public void println (char ch)
   {
-    print(new char[]{ch}, 0, 1, true);
+    print(new char[] { ch }, true);
   }
 
   /**
@@ -570,7 +588,7 @@
    */
   public void println (char[] charArray)
   {
-    print(charArray, 0, charArray.length, true);
+    print(charArray, true);
   }
 
   /**
@@ -584,10 +602,10 @@
   {
     try
       {
-        out.write (oneByte & 0xff);
+        out.write (oneByte);
 
         if (auto_flush && (oneByte == '\n'))
-          flush ();
+          out.flush();
       }
     catch (InterruptedIOException iioe)
       {
@@ -614,7 +632,7 @@
         out.write (buffer, offset, len);
 
         if (auto_flush)
-          flush ();
+          out.flush();
       }
     catch (InterruptedIOException iioe)
       {
@@ -643,7 +661,7 @@
   /** @since 1.5 */
   public PrintStream append(CharSequence cs, int start, int end)
   {
-    print(cs == null ? "null" : cs.subSequence(start, end).toString());
+    print((cs == null ? "null" : cs).subSequence(start, end).toString());
     return this;
   }
 
