/** * Adds an output stream; by default the stream will be auto-closed. * * @param stream * the stream to add to the T. * @return * the object itself, for method chaining. */ public TeeOutputStream with(OutputStream stream) { return with(stream, false); }
/** * @see java.io.DataOutput#writeShort(int) */ @Override public void writeShort(int value) throws IOException { byte [] buffer = { (byte)((value >>> 8) & 0xFF), (byte)((value >>> 0) & 0xFF) }; write(buffer, 0, buffer.length); }
/** * @see java.io.DataOutput#writeDouble(double) */ @Override public void writeDouble(double value) throws IOException { writeLong(Double.doubleToLongBits(value)); }
/** * @see java.io.DataOutput#writeFloat(float) */ @Override public void writeFloat(float value) throws IOException { writeInt(Float.floatToIntBits(value)); }
/** * @see java.io.DataOutput#writeChar(int) */ @Override public void writeChar(int value) throws IOException { byte [] buffer = { (byte)((value >>> 8) & 0xFF), (byte)((value >>> 0) & 0xFF) }; write(buffer, 0, buffer.length); }
/** * @see java.io.DataOutput#writeInt(int) */ @Override public void writeInt(int value) throws IOException { byte [] buffer = { (byte)((value >>> 24) & 0xFF), (byte)((value >>> 16) & 0xFF), (byte)((value >>> 8) & 0xFF), (byte)((value >>> 0) & 0xFF) }; write(buffer, 0, buffer.length); }
/** * @see java.io.DataOutput#writeLong(long) */ @Override public void writeLong(long value) throws IOException { byte buffer[] = { (byte)(value >>> 56), (byte)(value >>> 48), (byte)(value >>> 40), (byte)(value >>> 32), (byte)(value >>> 24), (byte)(value >>> 16), (byte)(value >>> 8), (byte)(value >>> 0) }; write(buffer, 0, buffer.length); }
/** * @see java.io.DataOutput#writeBytes(java.lang.String) */ @Override public void writeBytes(String string) throws IOException { byte[] buffer = new byte[string.length()]; for (int i = 0 ; i < buffer.length ; i++) { buffer[i] = (byte)string.charAt(i); } write(buffer, 0, buffer.length); }
/** * @see java.io.DataOutput#writeChars(java.lang.String) */ @Override public void writeChars(String string) throws IOException { int length = string.length(); byte [] buffer = new byte[length * 2]; for (int i = 0 ; i < length ; i+=2) { int v = string.charAt(i); buffer[i] = (byte)((v >>> 8) & 0xFF); buffer[i+1] = (byte)((v >>> 0) & 0xFF); } write(buffer, 0, buffer.length); }
write(buffer, 0, buffer.length);