From e391d57d2d9edfef8f1db29a6cd0d263f70daf60 Mon Sep 17 00:00:00 2001 From: mkoch Date: Fri, 1 Apr 2005 20:04:21 +0000 Subject: 2005-04-01 Michael Koch * java/io/PipedInputStream.java (read): Make sure a positive byte value is returned. Revised javadoc. Thanks to Olafur Bragason for reporting these bugs. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97416 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/java/io/PipedInputStream.java | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'libjava/java/io/PipedInputStream.java') diff --git a/libjava/java/io/PipedInputStream.java b/libjava/java/io/PipedInputStream.java index 906ef10fa9f..d424587889a 100644 --- a/libjava/java/io/PipedInputStream.java +++ b/libjava/java/io/PipedInputStream.java @@ -1,5 +1,5 @@ /* PipedInputStream.java -- Read portion of piped streams. - Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -226,18 +226,17 @@ public class PipedInputStream extends InputStream } /** - * This method reads bytes from the stream into a caller supplied buffer. - * It starts storing bytes at position offset into the - * buffer and - * reads a maximum of len bytes. Note that this method - * can actually - * read fewer than len bytes. The actual number of bytes - * read is - * returned. A -1 is returned to indicated that no bytes can be read + * This method reads one byte from the stream. + * -1 is returned to indicated that no bytes can be read * because the end of the stream was reached. If the stream is already * closed, a -1 will again be returned to indicate the end of the stream. - *

- * This method will block if no byte is available to be read. + * + *

This method will block if no byte is available to be read.

+ * + * @return the value of the read byte value, or -1 of the end of the stream + * was reached + * + * @throws IOException if an error occured */ public int read() throws IOException { @@ -248,7 +247,7 @@ public class PipedInputStream extends InputStream // if this method is never called. int r = read(read_buf, 0, 1); - return r != -1 ? read_buf[0] : -1; + return r != -1 ? (read_buf[0] & 0xff) : -1; } /** -- cgit v1.2.3