< prev index next >

src/java.base/share/classes/java/io/ObjectInputStream.java

Print this page




 836         desc.readNonProxy(this);
 837         return desc;
 838     }
 839 
 840     /**
 841      * Reads a byte of data. This method will block if no input is available.
 842      *
 843      * @return  the byte read, or -1 if the end of the stream is reached.
 844      * @throws  IOException If an I/O error has occurred.
 845      */
 846     public int read() throws IOException {
 847         return bin.read();
 848     }
 849 
 850     /**
 851      * Reads into an array of bytes.  This method will block until some input
 852      * is available. Consider using java.io.DataInputStream.readFully to read
 853      * exactly 'length' bytes.
 854      *
 855      * @param   buf the buffer into which the data is read
 856      * @param   off the start offset of the data
 857      * @param   len the maximum number of bytes read
 858      * @return  the actual number of bytes read, -1 is returned when the end of
 859      *          the stream is reached.




 860      * @throws  IOException If an I/O error has occurred.
 861      * @see java.io.DataInputStream#readFully(byte[],int,int)
 862      */
 863     public int read(byte[] buf, int off, int len) throws IOException {
 864         if (buf == null) {
 865             throw new NullPointerException();
 866         }
 867         int endoff = off + len;
 868         if (off < 0 || len < 0 || endoff > buf.length || endoff < 0) {
 869             throw new IndexOutOfBoundsException();
 870         }
 871         return bin.read(buf, off, len, false);
 872     }
 873 
 874     /**
 875      * Returns the number of bytes that can be read without blocking.
 876      *
 877      * @return  the number of available bytes.
 878      * @throws  IOException if there are I/O errors while reading from the
 879      *          underlying <code>InputStream</code>


 997      */
 998     public float readFloat() throws IOException {
 999         return bin.readFloat();
1000     }
1001 
1002     /**
1003      * Reads a 64 bit double.
1004      *
1005      * @return  the 64 bit double read.
1006      * @throws  EOFException If end of file is reached.
1007      * @throws  IOException If other I/O error has occurred.
1008      */
1009     public double readDouble() throws IOException {
1010         return bin.readDouble();
1011     }
1012 
1013     /**
1014      * Reads bytes, blocking until all bytes are read.
1015      *
1016      * @param   buf the buffer into which the data is read

1017      * @throws  EOFException If end of file is reached.
1018      * @throws  IOException If other I/O error has occurred.
1019      */
1020     public void readFully(byte[] buf) throws IOException {
1021         bin.readFully(buf, 0, buf.length, false);
1022     }
1023 
1024     /**
1025      * Reads bytes, blocking until all bytes are read.
1026      *
1027      * @param   buf the buffer into which the data is read
1028      * @param   off the start offset of the data
1029      * @param   len the maximum number of bytes to read




1030      * @throws  EOFException If end of file is reached.
1031      * @throws  IOException If other I/O error has occurred.
1032      */
1033     public void readFully(byte[] buf, int off, int len) throws IOException {
1034         int endoff = off + len;
1035         if (off < 0 || len < 0 || endoff > buf.length || endoff < 0) {
1036             throw new IndexOutOfBoundsException();
1037         }
1038         bin.readFully(buf, off, len, false);
1039     }
1040 
1041     /**
1042      * Skips bytes.
1043      *
1044      * @param   len the number of bytes to be skipped
1045      * @return  the actual number of bytes skipped.
1046      * @throws  IOException If an I/O error has occurred.
1047      */
1048     public int skipBytes(int len) throws IOException {
1049         return bin.skipBytes(len);




 836         desc.readNonProxy(this);
 837         return desc;
 838     }
 839 
 840     /**
 841      * Reads a byte of data. This method will block if no input is available.
 842      *
 843      * @return  the byte read, or -1 if the end of the stream is reached.
 844      * @throws  IOException If an I/O error has occurred.
 845      */
 846     public int read() throws IOException {
 847         return bin.read();
 848     }
 849 
 850     /**
 851      * Reads into an array of bytes.  This method will block until some input
 852      * is available. Consider using java.io.DataInputStream.readFully to read
 853      * exactly 'length' bytes.
 854      *
 855      * @param   buf the buffer into which the data is read
 856      * @param   off the start offset in the destination array {@code buf}
 857      * @param   len the maximum number of bytes read
 858      * @return  the actual number of bytes read, -1 is returned when the end of
 859      *          the stream is reached.
 860      * @throws  NullPointerException if {@code buf} is {@code null}.
 861      * @throws  IndexOutOfBoundsException if {@code off} is negative,
 862      *          {@code len} is negative, or {@code len} is greater than
 863      *          {@code buf.length - off}.
 864      * @throws  IOException If an I/O error has occurred.
 865      * @see java.io.DataInputStream#readFully(byte[],int,int)
 866      */
 867     public int read(byte[] buf, int off, int len) throws IOException {
 868         if (buf == null) {
 869             throw new NullPointerException();
 870         }
 871         int endoff = off + len;
 872         if (off < 0 || len < 0 || endoff > buf.length || endoff < 0) {
 873             throw new IndexOutOfBoundsException();
 874         }
 875         return bin.read(buf, off, len, false);
 876     }
 877 
 878     /**
 879      * Returns the number of bytes that can be read without blocking.
 880      *
 881      * @return  the number of available bytes.
 882      * @throws  IOException if there are I/O errors while reading from the
 883      *          underlying <code>InputStream</code>


1001      */
1002     public float readFloat() throws IOException {
1003         return bin.readFloat();
1004     }
1005 
1006     /**
1007      * Reads a 64 bit double.
1008      *
1009      * @return  the 64 bit double read.
1010      * @throws  EOFException If end of file is reached.
1011      * @throws  IOException If other I/O error has occurred.
1012      */
1013     public double readDouble() throws IOException {
1014         return bin.readDouble();
1015     }
1016 
1017     /**
1018      * Reads bytes, blocking until all bytes are read.
1019      *
1020      * @param   buf the buffer into which the data is read
1021      * @throws  NullPointerException If {@code buf} is {@code null}.
1022      * @throws  EOFException If end of file is reached.
1023      * @throws  IOException If other I/O error has occurred.
1024      */
1025     public void readFully(byte[] buf) throws IOException {
1026         bin.readFully(buf, 0, buf.length, false);
1027     }
1028 
1029     /**
1030      * Reads bytes, blocking until all bytes are read.
1031      *
1032      * @param   buf the buffer into which the data is read
1033      * @param   off the start offset into the data array {@code buf}
1034      * @param   len the maximum number of bytes to read
1035      * @throws  NullPointerException If {@code buf} is {@code null}.
1036      * @throws  IndexOutOfBoundsException If {@code off} is negative,
1037      *          {@code len} is negative, or {@code len} is greater than
1038      *          {@code buf.length - off}.
1039      * @throws  EOFException If end of file is reached.
1040      * @throws  IOException If other I/O error has occurred.
1041      */
1042     public void readFully(byte[] buf, int off, int len) throws IOException {
1043         int endoff = off + len;
1044         if (off < 0 || len < 0 || endoff > buf.length || endoff < 0) {
1045             throw new IndexOutOfBoundsException();
1046         }
1047         bin.readFully(buf, off, len, false);
1048     }
1049 
1050     /**
1051      * Skips bytes.
1052      *
1053      * @param   len the number of bytes to be skipped
1054      * @return  the actual number of bytes skipped.
1055      * @throws  IOException If an I/O error has occurred.
1056      */
1057     public int skipBytes(int len) throws IOException {
1058         return bin.skipBytes(len);


< prev index next >