This is the mail archive of the java-patches@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: PipedOutputStream.write


I'm committing this patch, which adds a missing method to
PipedOutputStream.

2000-02-03  Tom Tromey  <tromey@cygnus.com>

	* java/io/PipedOutputStream.java (write(byte[], int, int)): New
	method.

Tom

Index: java/io/PipedOutputStream.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/io/PipedOutputStream.java,v
retrieving revision 1.2
diff -u -r1.2 PipedOutputStream.java
--- PipedOutputStream.java	2000/01/19 18:39:25	1.2
+++ PipedOutputStream.java	2000/02/03 17:14:53
@@ -1,6 +1,6 @@
 // PipedOutputStream.java - Write bytes to a pipe.
 
-/* Copyright (C) 1998, 1999  Red Hat, Inc.
+/* Copyright (C) 1998, 1999, 2000  Red Hat, Inc.
 
    This file is part of libgcj.
 
@@ -81,12 +81,15 @@
     destination.receive(oneByte);
   }
 
-  // This is mentioned in the JCL book, but we don't really need it.
-  // If there were a corresponding receive() method on
-  // PipedInputStream then we could get better performance using
-  // this.
-  // public void write (byte[] buffer, int offset, int count)
-  // throws IOException;
+  public void write (byte[] buffer, int offset, int count) throws IOException
+  {
+    if (closed)
+      throw new IOException ();
+    if (offset < 0 || count < 0 || offset + count > buffer.length)
+      throw new ArrayIndexOutOfBoundsException ();
+    for (int i = 0; i < count; ++i)
+      destination.receive (buffer[offset + i]);
+  }
 
   // Instance variables.
   private PipedInputStream destination;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]