Interface DataInputStream
- All Superinterfaces:
AutoCloseable, Closeable
The data input stream provides a means for reading data from a stream.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanTests if the end of this stream has been reached.longGets the number ofbytesavailable for retrieval.voidclose()Closes this stream and frees up any allocated resources.longread(byte[] buf, long n) Reads a specified number ofbytesfrom this stream.longskip(long n) Skips a specified number ofbytesin the stream.
-
Method Details
-
atEndOfStream
boolean atEndOfStream()Tests if the end of this stream has been reached. This may not be a permanent condition as more data may be available at a later time as in the case of tailing a file.- Returns:
trueif the end of this stream has been reached,falseotherwise- Throws:
IllegalStateException- this stream has been closed- Compliance:
mandatory- This method must be implemented.
-
available
long available()Gets the number ofbytesavailable for retrieval. The number returned by this method may be less than or equal to the total number ofbytesin this stream.- Returns:
- the number of
bytesavailable for retrieval - Throws:
IllegalStateException- this stream has been closed- Compliance:
mandatory- This method must be implemented.
-
skip
long skip(long n) Skips a specified number ofbytesin the stream.- Parameters:
n- the number ofbytesto skip- Returns:
- the actual number of
bytesskipped - Throws:
IllegalStateException- this stream has been closed oratEndOfStream()istrue- Compliance:
mandatory- This method must be implemented.
-
read
Reads a specified number ofbytesfrom this stream.- Parameters:
buf- the buffer in which the data is readn- the number ofbytesto read- Returns:
- the actual number of
bytesread - Throws:
IllegalStateException- this stream has been closed oratEndOfStream()istrueInvalidArgumentException- the size ofbufis less thannNullArgumentException-bufisnullOperationFailedException- unable to complete request- Compliance:
mandatory- This method must be implemented.
-
close
void close()Closes this stream and frees up any allocated resources. Methods in this object may not be invoked after this method is called.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IllegalStateException- this stream has been closed- Compliance:
mandatory- This method must be implemented.
-