You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@locus.apache.org on 2000/07/10 18:14:40 UTC
cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector RequestStream.java
craigmcc 00/07/10 09:14:40
Modified: proposals/catalina/src/share/org/apache/tomcat/connector
RequestStream.java
Log:
Add byte-array versions of the read() method.
Revision Changes Path
1.4 +53 -4 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestStream.java
Index: RequestStream.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestStream.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RequestStream.java 2000/05/22 04:57:22 1.3
+++ RequestStream.java 2000/07/10 16:14:39 1.4
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestStream.java,v 1.3 2000/05/22 04:57:22 remm Exp $
- * $Revision: 1.3 $
- * $Date: 2000/05/22 04:57:22 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/connector/RequestStream.java,v 1.4 2000/07/10 16:14:39 craigmcc Exp $
+ * $Revision: 1.4 $
+ * $Date: 2000/07/10 16:14:39 $
*
* ====================================================================
*
@@ -79,7 +79,7 @@
* not reading more than that many bytes on the underlying stream.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.3 $ $Date: 2000/05/22 04:57:22 $
+ * @version $Revision: 1.4 $ $Date: 2000/07/10 16:14:39 $
*/
public class RequestStream
@@ -189,6 +189,55 @@
if (b >= 0)
count++;
return (b);
+
+ }
+
+
+ /**
+ * Read some number of bytes from the input stream, and store them
+ * into the buffer array b. The number of bytes actually read is
+ * returned as an integer. This method blocks until input data is
+ * available, end of file is detected, or an exception is thrown.
+ *
+ * @param b The buffer into which the data is read
+ *
+ * @exception IOException if an input/output error occurs
+ */
+ public int read(byte b[]) throws IOException {
+
+ return (read(b, 0, b.length));
+
+ }
+
+
+ /**
+ * Read up to <code>len</code> bytes of data from the input stream
+ * into an array of bytes. An attempt is made to read as many as
+ * <code>len</code> bytes, but a smaller number may be read,
+ * possibly zero. The number of bytes actually read is returned as
+ * an integer. This method blocks until input data is available,
+ * end of file is detected, or an exception is thrown.
+ *
+ * @param b The buffer into which the data is read
+ * @param off The start offset into array <code>b</code> at which
+ * the data is written
+ * @param len The maximum number of bytes to read
+ *
+ * @exception IOException if an input/output error occurs
+ */
+ public int read(byte b[], int off, int len) throws IOException {
+
+ int toRead = len;
+ if (length > 0) {
+ if (count >= length)
+ return (-1);
+ if ((count + len) > length)
+ toRead = length - count;
+ }
+ int actuallyRead = super.read(b, off, toRead);
+ if (actuallyRead >= 0)
+ count += actuallyRead;
+ return (actuallyRead);
}