public static byte[] toByteArray(DataGenerator dataGenerator) throws IOException { ByteArrayDataOutputStream buffer = new ByteArrayDataOutputStream(); dataGenerator.generateData(buffer); close(buffer); return buffer.toByteArray(); }
public static byte[] toByteArray(InputStream inputStream) throws IOException { ByteArrayDataOutputStream buffer = new ByteArrayDataOutputStream(); copy(inputStream, buffer); buffer.close(); return buffer.toByteArray(); }
public byte[] closeAndReturnData() { ByteArrayDataOutputStream buffer = (ByteArrayDataOutputStream) this.out; IOUtils.close(buffer); return buffer.toByteArray(); } }
public void writeNullableInt(Integer value) throws IOException { final boolean isNotNull = value != null; writeBoolean(isNotNull); if (isNotNull) { writeInt(value); } }
public void writeNullableByte(Byte value) throws IOException { final boolean isNotNull = value != null; writeBoolean(isNotNull); if (isNotNull) { writeByte(value); } }
public void writeNullableShort(Short value) throws IOException { final boolean isNotNull = value != null; writeBoolean(isNotNull); if (isNotNull) { writeShort(value); } }
public void writeNullableDouble(Float value) throws IOException { final boolean isNotNull = value != null; writeBoolean(isNotNull); if (isNotNull) { writeDouble(value); } }
public Short readNullableShort() throws IOException { if (readBoolean()) { return readShort(); } else { return null; } }
public void writeNullableFloat(Float value) throws IOException { final boolean isNotNull = value != null; writeBoolean(isNotNull); if (isNotNull) { writeFloat(value); } }
public Double readNullableDouble() throws IOException { if (readBoolean()) { return readDouble(); } else { return null; } }
public Float readNullableFloat() throws IOException { if (readBoolean()) { return readFloat(); } else { return null; } }
/** * Create a new byte array of specified size, and read data using {@link java.io.DataInput#readFully(byte[])} * * @param dataLen new buffer size * @return data read * @throws IOException If an error occured reading the data */ public byte[] readFully(int dataLen) throws IOException { return readFully(this, dataLen); }
private boolean checkWithinLimits(int size) throws DataLenghtLimitException { if ((count + size) > maxLen) { if (failOnTooMuchData) { throw new DataLenghtLimitException(); } else { return false; } } return true; } }
public Boolean readNullableBoolean() throws IOException { if (readBoolean()) { return readBoolean(); } else { return null; } }
public static byte[] toByteArray(InputStream inputStream) throws IOException { ByteArrayDataOutputStream buffer = new ByteArrayDataOutputStream(); copy(inputStream, buffer); buffer.close(); return buffer.toByteArray(); }
public void writeNullableInt(Integer value) throws IOException { final boolean isNotNull = value != null; writeBoolean(isNotNull); if (isNotNull) { writeInt(value); } }
public void writeNullableShort(Short value) throws IOException { final boolean isNotNull = value != null; writeBoolean(isNotNull); if (isNotNull) { writeShort(value); } }
public void writeNullableDouble(Float value) throws IOException { final boolean isNotNull = value != null; writeBoolean(isNotNull); if (isNotNull) { writeDouble(value); } }
/** * Create a new byte array of specified size, and read data using {@link java.io.DataInput#readFully(byte[])} * * @param dataLen new buffer size * @return data read * @throws IOException If an error occured reading the data */ public byte[] readFully(int dataLen) throws IOException { return readFully(this, dataLen); }
public static byte[] toByteArray(InputStream inputStream) throws IOException { ByteArrayDataOutputStream buffer = new ByteArrayDataOutputStream(); copy(inputStream, buffer); buffer.close(); return buffer.toByteArray(); }