A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way. An application uses a data output stream to write data that can later be read by a data input stream.
DataInputStream is not necessarily safe for multithreaded access. Thread safety is optional and is the responsibility of users of methods in this class.
A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way. An application uses a data output stream to write data that can later be read by a data input stream. DataInputStream is not necessarily safe for multithreaded access. Thread safety is optional and is the responsibility of users of methods in this class.
(*read-utf in)
Reads from the stream in a representation of a Unicode character string encoded in modified UTF-8 format; this string of characters is then returned as a String. The details of the modified UTF-8 representation are exactly the same as for the readUTF method of DataInput.
in - a data input stream. - java.io.DataInput
returns: a Unicode string. - java.lang.String
throws: java.io.EOFException - if the input stream reaches the end before all the bytes.
Reads from the stream in a representation of a Unicode character string encoded in modified UTF-8 format; this string of characters is then returned as a String. The details of the modified UTF-8 representation are exactly the same as for the readUTF method of DataInput. in - a data input stream. - `java.io.DataInput` returns: a Unicode string. - `java.lang.String` throws: java.io.EOFException - if the input stream reaches the end before all the bytes.
(->data-input-stream in)
Constructor.
Creates a DataInputStream that uses the specified underlying InputStream.
in - the specified input stream - java.io.InputStream
Constructor. Creates a DataInputStream that uses the specified underlying InputStream. in - the specified input stream - `java.io.InputStream`
(read this b)
(read this b off len)
Reads up to len bytes of data from the contained input stream into an array of bytes. An attempt is made to read as many as len 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.
If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.
The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.
In every case, elements b[0] through b[off] and elements b[off+len] through b[b.length-1] are unaffected.
b - the buffer into which the data is read. - byte[]
off - the start offset in the destination array b - int
len - the maximum number of bytes read. - int
returns: the total number of bytes read into the buffer, or
-1 if there is no more data because the end
of the stream has been reached. - int
throws: java.lang.NullPointerException - If b is null.
Reads up to len bytes of data from the contained input stream into an array of bytes. An attempt is made to read as many as len 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. If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b. The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected. In every case, elements b[0] through b[off] and elements b[off+len] through b[b.length-1] are unaffected. b - the buffer into which the data is read. - `byte[]` off - the start offset in the destination array b - `int` len - the maximum number of bytes read. - `int` returns: the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached. - `int` throws: java.lang.NullPointerException - If b is null.
(read-boolean this)
See the general contract of the readBoolean method of DataInput.
Bytes for this operation are read from the contained input stream.
returns: the boolean value read. - boolean
throws: java.io.EOFException - if this input stream has reached the end.
See the general contract of the readBoolean method of DataInput. Bytes for this operation are read from the contained input stream. returns: the boolean value read. - `boolean` throws: java.io.EOFException - if this input stream has reached the end.
(read-byte this)
See the general contract of the readByte method of DataInput.
Bytes for this operation are read from the contained input stream.
returns: the next byte of this input stream as a signed 8-bit
byte. - byte
throws: java.io.EOFException - if this input stream has reached the end.
See the general contract of the readByte method of DataInput. Bytes for this operation are read from the contained input stream. returns: the next byte of this input stream as a signed 8-bit byte. - `byte` throws: java.io.EOFException - if this input stream has reached the end.
(read-char this)
See the general contract of the readChar method of DataInput.
Bytes for this operation are read from the contained input stream.
returns: the next two bytes of this input stream, interpreted as a
char. - char
throws: java.io.EOFException - if this input stream reaches the end before reading two bytes.
See the general contract of the readChar method of DataInput. Bytes for this operation are read from the contained input stream. returns: the next two bytes of this input stream, interpreted as a char. - `char` throws: java.io.EOFException - if this input stream reaches the end before reading two bytes.
(read-double this)
See the general contract of the readDouble method of DataInput.
Bytes for this operation are read from the contained input stream.
returns: the next eight bytes of this input stream, interpreted as a
double. - double
throws: java.io.EOFException - if this input stream reaches the end before reading eight bytes.
See the general contract of the readDouble method of DataInput. Bytes for this operation are read from the contained input stream. returns: the next eight bytes of this input stream, interpreted as a double. - `double` throws: java.io.EOFException - if this input stream reaches the end before reading eight bytes.
(read-float this)
See the general contract of the readFloat method of DataInput.
Bytes for this operation are read from the contained input stream.
returns: the next four bytes of this input stream, interpreted as a
float. - float
throws: java.io.EOFException - if this input stream reaches the end before reading four bytes.
See the general contract of the readFloat method of DataInput. Bytes for this operation are read from the contained input stream. returns: the next four bytes of this input stream, interpreted as a float. - `float` throws: java.io.EOFException - if this input stream reaches the end before reading four bytes.
(read-fully this b)
(read-fully this b off len)
See the general contract of the readFully method of DataInput.
Bytes for this operation are read from the contained input stream.
b - the buffer into which the data is read. - byte[]
off - the start offset of the data. - int
len - the number of bytes to read. - int
throws: java.io.EOFException - if this input stream reaches the end before reading all the bytes.
See the general contract of the readFully method of DataInput. Bytes for this operation are read from the contained input stream. b - the buffer into which the data is read. - `byte[]` off - the start offset of the data. - `int` len - the number of bytes to read. - `int` throws: java.io.EOFException - if this input stream reaches the end before reading all the bytes.
(read-int this)
See the general contract of the readInt method of DataInput.
Bytes for this operation are read from the contained input stream.
returns: the next four bytes of this input stream, interpreted as an
int. - int
throws: java.io.EOFException - if this input stream reaches the end before reading four bytes.
See the general contract of the readInt method of DataInput. Bytes for this operation are read from the contained input stream. returns: the next four bytes of this input stream, interpreted as an int. - `int` throws: java.io.EOFException - if this input stream reaches the end before reading four bytes.
(read-line this)
Deprecated. This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form:
DataInputStream d = new DataInputStream(in);
with:
BufferedReader d
= new BufferedReader(new InputStreamReader(in));
returns: the next line of text from this input stream. - java.lang.String
throws: java.io.IOException - if an I/O error occurs.
Deprecated. This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form: DataInputStream d = new DataInputStream(in); with: BufferedReader d = new BufferedReader(new InputStreamReader(in)); returns: the next line of text from this input stream. - `java.lang.String` throws: java.io.IOException - if an I/O error occurs.
(read-long this)
See the general contract of the readLong method of DataInput.
Bytes for this operation are read from the contained input stream.
returns: the next eight bytes of this input stream, interpreted as a
long. - long
throws: java.io.EOFException - if this input stream reaches the end before reading eight bytes.
See the general contract of the readLong method of DataInput. Bytes for this operation are read from the contained input stream. returns: the next eight bytes of this input stream, interpreted as a long. - `long` throws: java.io.EOFException - if this input stream reaches the end before reading eight bytes.
(read-short this)
See the general contract of the readShort method of DataInput.
Bytes for this operation are read from the contained input stream.
returns: the next two bytes of this input stream, interpreted as a
signed 16-bit number. - short
throws: java.io.EOFException - if this input stream reaches the end before reading two bytes.
See the general contract of the readShort method of DataInput. Bytes for this operation are read from the contained input stream. returns: the next two bytes of this input stream, interpreted as a signed 16-bit number. - `short` throws: java.io.EOFException - if this input stream reaches the end before reading two bytes.
(read-unsigned-byte this)
See the general contract of the readUnsignedByte method of DataInput.
Bytes for this operation are read from the contained input stream.
returns: the next byte of this input stream, interpreted as an
unsigned 8-bit number. - int
throws: java.io.EOFException - if this input stream has reached the end.
See the general contract of the readUnsignedByte method of DataInput. Bytes for this operation are read from the contained input stream. returns: the next byte of this input stream, interpreted as an unsigned 8-bit number. - `int` throws: java.io.EOFException - if this input stream has reached the end.
(read-unsigned-short this)
See the general contract of the readUnsignedShort method of DataInput.
Bytes for this operation are read from the contained input stream.
returns: the next two bytes of this input stream, interpreted as an
unsigned 16-bit integer. - int
throws: java.io.EOFException - if this input stream reaches the end before reading two bytes.
See the general contract of the readUnsignedShort method of DataInput. Bytes for this operation are read from the contained input stream. returns: the next two bytes of this input stream, interpreted as an unsigned 16-bit integer. - `int` throws: java.io.EOFException - if this input stream reaches the end before reading two bytes.
(read-utf this)
See the general contract of the readUTF method of DataInput.
Bytes for this operation are read from the contained input stream.
returns: a Unicode string. - java.lang.String
throws: java.io.EOFException - if this input stream reaches the end before reading all the bytes.
See the general contract of the readUTF method of DataInput. Bytes for this operation are read from the contained input stream. returns: a Unicode string. - `java.lang.String` throws: java.io.EOFException - if this input stream reaches the end before reading all the bytes.
(skip-bytes this n)
See the general contract of the skipBytes method of DataInput.
Bytes for this operation are read from the contained input stream.
n - the number of bytes to be skipped. - int
returns: the actual number of bytes skipped. - int
throws: java.io.IOException - if the contained input stream does not support seek, or the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
See the general contract of the skipBytes method of DataInput. Bytes for this operation are read from the contained input stream. n - the number of bytes to be skipped. - `int` returns: the actual number of bytes skipped. - `int` throws: java.io.IOException - if the contained input stream does not support seek, or the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close