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.

public void writeShort(int s) throws <strong>IO</strong>Exception {<br />

}<br />

out.write(s & 0xFF);<br />

out.write((s >>> 8) & 0xFF);<br />

written += 2;<br />

/**<br />

* Writes a two byte char to the underlying output stream<br />

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

*<br />

* @param c the char value to be written.<br />

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

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

*/<br />

public void writeChar(int c) throws <strong>IO</strong>Exception {<br />

}<br />

out.write(c & 0xFF);<br />

out.write((c >>> 8) & 0xFF);<br />

written += 2;<br />

/**<br />

* Writes a four-byte int to the underlying output stream<br />

* in little-endian order, low byte first, high byte last<br />

*<br />

* @param i the int to be written.<br />

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

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

*/<br />

public void writeInt(int i) throws <strong>IO</strong>Exception {<br />

}<br />

out.write(i & 0xFF);<br />

out.write((i >>> 8) & 0xFF);<br />

out.write((i >>> 16) & 0xFF);<br />

out.write((i >>> 24) & 0xFF);<br />

written += 4;<br />

<strong>Java</strong> I/O<br />

/**<br />

* Writes an eight-byte long to the underlying output stream<br />

* in little-endian order, low byte first, high byte last<br />

*<br />

* @param l the long to be written.<br />

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

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

*/<br />

public void writeLong(long l) throws <strong>IO</strong>Exception {<br />

}<br />

out.write((int) l & 0xFF);<br />

out.write((int) (l >>> 8) & 0xFF);<br />

out.write((int) (l >>> 16) & 0xFF);<br />

out.write((int) (l >>> 24) & 0xFF);<br />

out.write((int) (l >>> 32) & 0xFF);<br />

out.write((int) (l >>> 40) & 0xFF);<br />

out.write((int) (l >>> 48) & 0xFF);<br />

out.write((int) (l >>> 56) & 0xFF);<br />

written += 8;<br />

114

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

Saved successfully!

Ooh no, something went wrong!