< prev index next >

src/java.base/share/classes/javax/crypto/CipherInputStream.java

Print this page




 191             if (i == -1) return -1;
 192         }
 193         return ((int) obuffer[ostart++] & 0xff);
 194     };
 195 
 196     /**
 197      * Reads up to <code>b.length</code> bytes of data from this input
 198      * stream into an array of bytes.
 199      * <p>
 200      * The <code>read</code> method of <code>InputStream</code> calls
 201      * the <code>read</code> method of three arguments with the arguments
 202      * <code>b</code>, <code>0</code>, and <code>b.length</code>.
 203      *
 204      * @param      b   the buffer into which the data is read.
 205      * @return     the total number of bytes read into the buffer, or
 206      *             <code>-1</code> is there is no more data because the end of
 207      *             the stream has been reached.
 208      * @exception  IOException  if an I/O error occurs.
 209      * @see        java.io.InputStream#read(byte[], int, int)
 210      */
 211     public int read(byte b[]) throws IOException {
 212         return read(b, 0, b.length);
 213     }
 214 
 215     /**
 216      * Reads up to <code>len</code> bytes of data from this input stream
 217      * into an array of bytes. This method blocks until some input is
 218      * available. If the first argument is <code>null,</code> up to
 219      * <code>len</code> bytes are read and discarded.
 220      *
 221      * @param      b     the buffer into which the data is read.
 222      * @param      off   the start offset in the destination array
 223      *                   <code>buf</code>
 224      * @param      len   the maximum number of bytes read.
 225      * @return     the total number of bytes read into the buffer, or
 226      *             <code>-1</code> if there is no more data because the end of
 227      *             the stream has been reached.
 228      * @exception  IOException  if an I/O error occurs.
 229      * @see        java.io.InputStream#read()
 230      */
 231     public int read(byte b[], int off, int len) throws IOException {
 232         if (ostart >= ofinish) {
 233             // we loop for new data as the spec says we are blocking
 234             int i = 0;
 235             while (i == 0) i = getMoreData();
 236             if (i == -1) return -1;
 237         }
 238         if (len <= 0) {
 239             return 0;
 240         }
 241         int available = ofinish - ostart;
 242         if (len < available) available = len;
 243         if (b != null) {
 244             System.arraycopy(obuffer, ostart, b, off, available);
 245         }
 246         ostart = ostart + available;
 247         return available;
 248     }
 249 
 250     /**
 251      * Skips <code>n</code> bytes of input from the bytes that can be read




 191             if (i == -1) return -1;
 192         }
 193         return ((int) obuffer[ostart++] & 0xff);
 194     };
 195 
 196     /**
 197      * Reads up to <code>b.length</code> bytes of data from this input
 198      * stream into an array of bytes.
 199      * <p>
 200      * The <code>read</code> method of <code>InputStream</code> calls
 201      * the <code>read</code> method of three arguments with the arguments
 202      * <code>b</code>, <code>0</code>, and <code>b.length</code>.
 203      *
 204      * @param      b   the buffer into which the data is read.
 205      * @return     the total number of bytes read into the buffer, or
 206      *             <code>-1</code> is there is no more data because the end of
 207      *             the stream has been reached.
 208      * @exception  IOException  if an I/O error occurs.
 209      * @see        java.io.InputStream#read(byte[], int, int)
 210      */
 211     public int read(byte[] b) throws IOException {
 212         return read(b, 0, b.length);
 213     }
 214 
 215     /**
 216      * Reads up to <code>len</code> bytes of data from this input stream
 217      * into an array of bytes. This method blocks until some input is
 218      * available. If the first argument is <code>null,</code> up to
 219      * <code>len</code> bytes are read and discarded.
 220      *
 221      * @param      b     the buffer into which the data is read.
 222      * @param      off   the start offset in the destination array
 223      *                   <code>buf</code>
 224      * @param      len   the maximum number of bytes read.
 225      * @return     the total number of bytes read into the buffer, or
 226      *             <code>-1</code> if there is no more data because the end of
 227      *             the stream has been reached.
 228      * @exception  IOException  if an I/O error occurs.
 229      * @see        java.io.InputStream#read()
 230      */
 231     public int read(byte[] b, int off, int len) throws IOException {
 232         if (ostart >= ofinish) {
 233             // we loop for new data as the spec says we are blocking
 234             int i = 0;
 235             while (i == 0) i = getMoreData();
 236             if (i == -1) return -1;
 237         }
 238         if (len <= 0) {
 239             return 0;
 240         }
 241         int available = ofinish - ostart;
 242         if (len < available) available = len;
 243         if (b != null) {
 244             System.arraycopy(obuffer, ostart, b, off, available);
 245         }
 246         ostart = ostart + available;
 247         return available;
 248     }
 249 
 250     /**
 251      * Skips <code>n</code> bytes of input from the bytes that can be read


< prev index next >