23.07.2013 Views

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

*/<br />

public byte readByte(int b) throws <strong>IO</strong>Exception {<br />

}<br />

int temp = in.read();<br />

if (temp == -1) throw new EOFException();<br />

return (byte) temp;<br />

/**<br />

* Reads an unsigned byte from the underlying<br />

* input stream with value between 0 and 255.<br />

*<br />

* @return the byte value read.<br />

* @exception EOFException if the end of the underlying input<br />

* stream has been reached<br />

* @exception <strong>IO</strong>Exception if the underlying stream throws an<br />

<strong>IO</strong>Exception.<br />

*/<br />

public int readUnsignedByte() throws <strong>IO</strong>Exception {<br />

}<br />

int temp = in.read();<br />

if (temp == -1) throw new EOFException();<br />

return temp;<br />

/**<br />

* Reads a two byte signed short from the underlying<br />

* input stream in little-endian order, low byte first.<br />

*<br />

* @return the short read.<br />

* @exception EOFException if the end of the underlying input stream<br />

* has been reached<br />

* @exception <strong>IO</strong>Exception if the underlying stream throws an<br />

<strong>IO</strong>Exception.<br />

*/<br />

public short readShort() throws <strong>IO</strong>Exception {<br />

}<br />

int byte1 = in.read();<br />

int byte2 = in.read();<br />

// only need to test last byte read<br />

// if byte1 is -1 so is byte2<br />

if (byte2 == -1) throw new EOFException();<br />

return (short) ((byte2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!