@Override public void writeByte(int v) throws IOException { work[0] = (byte) (v & 0xff); write(work, 0, 1); }
@Override public boolean readBoolean() throws IOException { readFully(work, 0, 1); return work[0] != 0; }
@Override protected void archiveState(Archive ar) throws IOException { nextTask = ar.archiveInt(nextTask); tasksComplete = ar.archiveInt(tasksComplete); }
/** * Writes the specified byte array to a file. * @param file The <code>File</code> to write. * @param contents The byte array to write to the file. * @throws IOException If the file could not be written. */ public static void setFileContents(File file, ByteBuffer contents) throws IOException { setFileContents(file, contents, false); }
/** * Gets the single instance of <code>NullOutputStream</code>. * @return The single instance of <code>NullOutputStream</code>. */ public static NullOutputStream getInstance() { if (instance == null) { instance = new NullOutputStream(); } return instance; }
@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public void write(byte[] b) { write(b, 0, b.length); }
@Override public int readUnsignedShort() throws IOException { return ((int) readShort()) & 0xffff; }
@Override public void writeBoolean(boolean v) throws IOException { work[0] = (byte) (v ? 1 : 0); write(work, 0, 1); }
@Override public byte readByte() throws IOException { readFully(work, 0, 1); return work[0]; }
@Override protected void archiveState(Archive ar) throws IOException { nextTask = ar.archiveInt(nextTask); numResultsReceived = ar.archiveInt(numResultsReceived); }
/** * Writes the specified byte array to a file. * @param file The <code>File</code> to write. * @param contents The byte array to write to the file. * @throws IOException If the file could not be written. */ public static void setFileContents(File file, byte[] contents) throws IOException { setFileContents(file, contents, false); }
@Override public void writeShort(int v) throws IOException { work[0] = (byte) (0xff & v); work[1] = (byte) (0xff & (v >> 8)); write(work, 0, 2); }
@Override public char readChar() throws IOException { readFully(work, 0, 2); return (char) ((work[1] << 8) | (work[0] & 0xff)); }
@Override protected void archiveState(Archive ar) throws IOException { nextTask = ar.archiveInt(nextTask); tasksComplete = ar.archiveInt(tasksComplete); }
@Override public void writeChar(int v) throws IOException { work[0] = (byte) (0xff & v); work[1] = (byte) (0xff & (v >> 8)); write(work, 0, 2); }
@Override public int readInt() throws IOException { readFully(work, 0, 4); return (((int) work[0]) & 0xff) | (((int) work[1]) & 0xff) << 8 | (((int) work[2]) & 0xff) << 16 | (((int) work[3]) & 0xff) << 24; }
@Override public void writeInt(int v) throws IOException { work[0] = (byte) (0xffL & v); work[1] = (byte) (0xffL & (v >> 8)); work[2] = (byte) (0xffL & (v >> 16)); work[3] = (byte) (0xffL & (v >> 24)); write(work, 0, 8); }
@Override public short readShort() throws IOException { readFully(work, 0, 2); return (short) ( (((int) work[0]) & 0xff) | (((int) work[1]) & 0xff) << 8); }
@Override public void writeLong(long v) throws IOException { work[0] = (byte) (0xffL & v); work[1] = (byte) (0xffL & (v >> 8)); work[2] = (byte) (0xffL & (v >> 16)); work[3] = (byte) (0xffL & (v >> 24)); work[4] = (byte) (0xffL & (v >> 32)); work[5] = (byte) (0xffL & (v >> 40)); work[6] = (byte) (0xffL & (v >> 48)); work[7] = (byte) (0xffL & (v >> 56)); write(work, 0, 8); }