Package org.eclipse.birt.core.util
Class IOUtil
java.lang.Object
org.eclipse.birt.core.util.IOUtil
A util class to read or write primitive Java data type. Please notice, every
method has a stream which might be input stream or output stream as
parameters. This stream should be already added a buffered layer underlying
it.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprotected static Loggerstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final intbytesToInteger(byte[] b) Assemble four bytes to an int value, make sure that the passed bytes length is larger than 4.static final longbytesToLong(byte[] b) Assemble eight bytes to an long value, make sure that the passed bytes length larger than 8.static final intgetInt(byte[] bytes) Assemble four bytes to an int value, make sure that the passed bytes length is 4.static intgetTypeIndex(Object obValue) from object class to its type index valuestatic final voidintegerToBytes(int v, byte[] b) static final voidlongToBytes(long v, byte[] b) static final <T> Tread(DataInputStream inputStream, Class<T> clazz) static final booleanreadBool(InputStream inputStream) Read a bool value from an input streamstatic final byte[]readBytes(DataInputStream dis) Read a list from an input streamstatic final doublereadDouble(DataInputStream inputStream) Read a double value from an input streamstatic final floatreadFloat(DataInputStream inputStream) Read a float value from an input streamstatic final intreadInt(InputStream inputStream) Read an int value from an input streamstatic final Liststatic final ListreadList(DataInputStream dis) Read a list from an input streamstatic final ListreadList(DataInputStream dis, ClassLoader classLoader) Read a list from an input streamstatic final longreadLong(DataInputStream inputStream) Read a long value from an input streamstatic final MapreadMap(DataInputStream dis) Read a Map from an input streamstatic final MapreadMap(DataInputStream dis, ClassLoader loader) Read a Map from an input streamstatic final ObjectCurrently these data types are supported.static final ObjectreadObject(DataInputStream dis, ClassLoader classLoader) Currently these data types are supported.static final shortreadShort(InputStream inputStream) Read an int value from an input streamstatic final StringRead a String from an input streamstatic final <T> voidwrite(DataOutputStream out, T object, Class<T> clazz) static final voidwriteBool(OutputStream outputStream, boolean bool) Write a boolean value to an output streamstatic final voidwriteBytes(DataOutputStream dos, byte[] bytes) Write a bytes to an output streamstatic final voidwriteDouble(DataOutputStream outputStream, double value) Write a double value to an output streamstatic final voidwriteFloat(DataOutputStream outputStream, float value) Write a float value to an output streamstatic final voidwriteInt(OutputStream outputStream, int value) Write an int value to an output streamstatic final voidwriteIntList(DataOutputStream dos, List list) static final voidwriteList(DataOutputStream dos, List list) Write a list to an output streamstatic final voidwriteLong(DataOutputStream outputStream, long value) Write a long value to an output streamstatic final voidwriteMap(DataOutputStream dos, Map map) Write a Map to an output streamstatic final voidwriteObject(DataOutputStream dos, Object obValue) When obValue is not supported te be serialized, an IOException will be thrown.static final voidwriteRawBytes(DataOutputStream dos, byte[] bytes) Write a byte array to an output stream only with its raw content.static final voidwriteShort(OutputStream outputStream, short value) Write an int value to an output streamstatic final voidwriteString(DataOutputStream dos, String str) Write a String value to an output stream
-
Field Details
-
INT_LENGTH
public static final int INT_LENGTH- See Also:
-
LONG_LENGTH
public static final int LONG_LENGTH- See Also:
-
RA_STREAM_BUFFER_LENGTH
public static final int RA_STREAM_BUFFER_LENGTH- See Also:
-
MAX_NUMBER_OF_STREAM_BUFFER
public static final int MAX_NUMBER_OF_STREAM_BUFFER- See Also:
-
logger
-
-
Constructor Details
-
IOUtil
public IOUtil()
-
-
Method Details
-
read
- Throws:
IOException
-
write
public static final <T> void write(DataOutputStream out, T object, Class<T> clazz) throws IOException - Throws:
IOException
-
readShort
Read an int value from an input stream- Parameters:
inputStream-- Returns:
- int value
- Throws:
IOException
-
writeShort
Write an int value to an output stream- Parameters:
outputStream-value-- Throws:
IOException
-
readInt
Read an int value from an input stream- Parameters:
inputStream-- Returns:
- int value
- Throws:
IOException
-
writeInt
Write an int value to an output stream- Parameters:
outputStream-value-- Throws:
IOException
-
getInt
public static final int getInt(byte[] bytes) Assemble four bytes to an int value, make sure that the passed bytes length is 4.- Parameters:
bytes-- Returns:
- int value of bytes
-
bytesToInteger
public static final int bytesToInteger(byte[] b) Assemble four bytes to an int value, make sure that the passed bytes length is larger than 4.- Parameters:
bytes-- Returns:
- int value of bytes
-
bytesToLong
public static final long bytesToLong(byte[] b) Assemble eight bytes to an long value, make sure that the passed bytes length larger than 8.- Parameters:
bytes-- Returns:
- int value of bytes
-
integerToBytes
public static final void integerToBytes(int v, byte[] b) -
longToBytes
public static final void longToBytes(long v, byte[] b) -
readBool
Read a bool value from an input stream- Parameters:
inputStream-- Returns:
- boolean value
- Throws:
IOException
-
writeBool
Write a boolean value to an output stream- Parameters:
outputStream-bool-- Throws:
IOException
-
readFloat
Read a float value from an input stream- Parameters:
inputStream-- Returns:
- int value
- Throws:
IOException
-
writeFloat
Write a float value to an output stream- Parameters:
outputStream-value-- Throws:
IOException
-
readDouble
Read a double value from an input stream- Parameters:
inputStream-- Returns:
- int value
- Throws:
IOException
-
writeDouble
public static final void writeDouble(DataOutputStream outputStream, double value) throws IOException Write a double value to an output stream- Parameters:
outputStream-value-- Throws:
IOException
-
readLong
Read a long value from an input stream- Parameters:
inputStream-- Returns:
- int value
- Throws:
IOException
-
writeLong
Write a long value to an output stream- Parameters:
outputStream-value-- Throws:
IOException
-
writeRawBytes
Write a byte array to an output stream only with its raw content.- Parameters:
dos-bytes- , it can not be null- Throws:
IOException
-
getTypeIndex
from object class to its type index value- Parameters:
obValue-- Returns:
-
readObject
Currently these data types are supported. Integer Float Double BigDecimal Date Time Timestamp Boolean String byte[] List Map- Returns:
- Throws:
IOException
-
readObject
public static final Object readObject(DataInputStream dis, ClassLoader classLoader) throws IOException Currently these data types are supported. Integer Float Double BigDecimal Date Time Timestamp Boolean String byte[] List Map- Returns:
- Throws:
IOException
-
writeObject
When obValue is not supported te be serialized, an IOException will be thrown.- Parameters:
dos-obValue-- Throws:
IOException
-
readString
Read a String from an input stream- Parameters:
inputStream-- Returns:
- an String
- Throws:
IOException
-
writeString
Write a String value to an output stream- Parameters:
outputStream-str-- Throws:
IOException
-
readBytes
Read a list from an input stream- Parameters:
dos-- Returns:
- Throws:
IOExceptionBirtException
-
writeBytes
Write a bytes to an output stream- Parameters:
dos-dataMap-- Throws:
IOExceptionBirtException
-
readList
Read a list from an input stream- Parameters:
dos-- Returns:
- Throws:
IOExceptionBirtException
-
readList
Read a list from an input stream- Parameters:
dos-- Returns:
- Throws:
IOExceptionBirtException
-
readIntList
- Throws:
IOException
-
writeList
Write a list to an output stream- Parameters:
dos-dataMap-- Throws:
IOExceptionBirtException
-
writeIntList
- Throws:
IOException
-
readMap
Read a Map from an input stream- Parameters:
dos-- Returns:
- Throws:
IOExceptionBirtException
-
readMap
Read a Map from an input stream- Parameters:
dos-- Returns:
- Throws:
IOExceptionBirtException
-
writeMap
Write a Map to an output stream- Parameters:
dos-map-- Throws:
IOExceptionBirtException
-