|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.io.InputStream
squint.DataInputChannel
public class DataInputChannel
A DataInputChannel is a stream designed to provide mechanisms to access data stored or transmitted using distinct binary encoding schemes for various types of data (i.e. not just ASCII or UniCode). Objects of this class are used by the TCPConnection class for the "in" stream associated with a TCPConnection. It is also possible to create a DataInputStream that provides access to data stored in a disk file. The interface to a DataInputChannel is desiged to be very similar to the interface to a standard DataInputStream, except that the methods of this class never throw checked exceptions. This makes it possible to use this class without inserting try/catch constructs around code that uses the class. In many cases, more complete descriptions of the behavior of the methods of this class can be found in the descriptions of the corresponding methods of the standard Java DataInput interface.
| Constructor Summary | |
|---|---|
DataInputChannel(java.io.File f)
Create a DataInputStream to access the data stored within a file given a File object describing the desired file. |
|
DataInputChannel(java.io.InputStream source)
Create a DataInputStream given an InputStream to use to actually perform data transfer. |
|
DataInputChannel(java.lang.String fileName)
Create a DataInputStream given a pathname within the local file system that identifies the desired file. |
|
| Method Summary | |
|---|---|
int |
available()
Determine how many bytes/characters of data are currently available through a channel. |
void |
close()
Close the channel. |
int |
read()
Access the next byte of data available through the channel. |
int |
read(byte[] buffer)
Access any currently available bytes of data received through the channel. |
int |
read(byte[] buffer,
int off,
int len)
Access any currently available bytes of data received through the channel. |
boolean |
readBoolean()
Access the next byte of data available through the channel treating it as a boolean value. |
byte |
readByte()
Access the next byte of data available through the channel. |
char |
readChar()
Access the next character of data available through the channel. |
double |
readDouble()
Access the next double value available through the channel. |
float |
readFloat()
Access the next float value available through the channel. |
void |
readFully(byte[] buffer)
Read some bytes from an input channel and store them into the array buffer. |
void |
readFully(byte[] buffer,
int off,
int len)
Read some bytes from an input channel and store them into the array buffer. |
int |
readInt()
Access the next 4 byte int value available through the channel. |
java.lang.String |
readLine()
Read a line of text from the input channel treating each byte as an ASCII character. |
long |
readLong()
Access the next 8 byte integer value available through the channel. |
short |
readShort()
Access the next 2 byte integer value available through the channel. |
java.lang.String |
readString()
Access any currently available characters of data received through the channel. |
java.lang.String |
readString(int desired)
Access any currently available characters of data received through the channel. |
int |
readUnsignedByte()
Access the next byte of data available through the channel. |
int |
readUnsignedShort()
Access the next 2 byte integer value available through the channel. |
java.lang.String |
readUTF()
Read a string encoded in modified UTF-8 format. |
int |
skipBytes(int len)
Skip a specified number of bytes of incoming data . |
| Methods inherited from class java.io.InputStream |
|---|
mark, markSupported, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DataInputChannel(java.io.File f)
f - the file to be accessed.public DataInputChannel(java.lang.String fileName)
fileName - the full path name of the file to be accessed through the stream.public DataInputChannel(java.io.InputStream source)
source - the underlying InputStream through which the data accessed
will pass.| Method Detail |
|---|
public void close()
close in interface java.io.Closeableclose in class java.io.InputStreampublic int skipBytes(int len)
skipBytes in interface java.io.DataInputlen - the number of bytes of data to skip
public int available()
available in class java.io.InputStreampublic java.lang.String readLine()
readLine in interface java.io.DataInputpublic java.lang.String readString(int desired)
desired - an upper limit on the number of bytes/characters of data
desired. The method may return fewer bytes if the desired
number are not currently available.
public java.lang.String readString()
public byte readByte()
readByte in interface java.io.DataInputpublic char readChar()
readChar in interface java.io.DataInputpublic double readDouble()
readDouble in interface java.io.DataInputpublic float readFloat()
readFloat in interface java.io.DataInputpublic boolean readBoolean()
readBoolean in interface java.io.DataInputpublic int readInt()
readInt in interface java.io.DataInputpublic short readShort()
readShort in interface java.io.DataInputpublic long readLong()
readLong in interface java.io.DataInputpublic int readUnsignedByte()
readUnsignedByte in interface java.io.DataInputpublic int readUnsignedShort()
readUnsignedShort in interface java.io.DataInputpublic int read()
read in class java.io.InputStreampublic int read(byte[] buffer)
read in class java.io.InputStreambuffer - An array to hold the data actually retrieved.
public int read(byte[] buffer,
int off,
int len)
read in class java.io.InputStreambuffer - An array to hold the data actually retrieved.off - the offset within the buffer array at which the first
byte should be placedlen - a limit on the number of bytes to be retrieved
public void readFully(byte[] buffer)
readFully in interface java.io.DataInputbuffer - a byte array in which the data obtained should be placed
public void readFully(byte[] buffer,
int off,
int len)
readFully in interface java.io.DataInputbuffer - a byte array in which the data obtained should be placedoff - offset within the buffer array at which first byte should be placedlen - number of bytes to readpublic java.lang.String readUTF()
readUTF in interface java.io.DataInput
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||