Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://download.oracle.com/javase/7/docs/api/java/io/DataInput.html#readBoolean%28%29"><code>readBoolean()</code></a> reads a single byte. <a href="http://download.oracle.com/javase/7/docs/api/java/io/DataInput.html#readLine%28%29"><code>readLine()</code></a> reads single bytes and converts each to a <code>char</code>.</p> <p><a href="http://download.oracle.com/javase/7/docs/api/java/io/DataInput.html#readUTF%28%29"><code>readUTF()</code></a> reads modified UTF-8 (which has a code unit size of one octet). UTF-8 has <a href="http://unicode.org/faq/utf_bom.html#utf8-2">no endianness</a>.</p> <p>There are no endianness concerns with these methods.</p> <p>As to the design, consider whether the type needs to be an <code>InputStream</code> and whether the <a href="http://download.oracle.com/javase/7/docs/api/java/nio/ByteBuffer.html"><code>ByteBuffer</code></a> might be useful. If you weren't using features like mark/reset and <a href="http://download.oracle.com/javase/7/docs/api/java/io/Closeable.html"><code>Closeable</code></a> you might not expose the new type:</p> <pre><code>public class Bytes { public static DataInput littleEndian(final DataInput decorated) { class LittleInput implements DataInput { private ByteBuffer buffer = ByteBuffer.allocate(8); public int readInt() throws IOException { buffer.clear(); buffer.order(ByteOrder.BIG_ENDIAN) .putInt(decorated.readInt()) .flip(); return buffer.order(ByteOrder.LITTLE_ENDIAN) .getInt(); } //TODO: other methods } return new LittleInput(); } } </code></pre> <p>I note that the popular Guava library already has <a href="http://docs.guava-libraries.googlecode.com/git-history/v10.0.1/javadoc/com/google/common/io/LittleEndianDataInputStream.html">LittleEndianDataInputStream</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload