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 int
protected static Logger
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final int
bytesToInteger
(byte[] b) Assemble four bytes to an int value, make sure that the passed bytes length is larger than 4.static final long
bytesToLong
(byte[] b) Assemble eight bytes to an long value, make sure that the passed bytes length larger than 8.static final int
getInt
(byte[] bytes) Assemble four bytes to an int value, make sure that the passed bytes length is 4.static int
getTypeIndex
(Object obValue) from object class to its type index valuestatic final void
integerToBytes
(int v, byte[] b) static final void
longToBytes
(long v, byte[] b) static final <T> T
read
(DataInputStream inputStream, Class<T> clazz) static final boolean
readBool
(InputStream inputStream) Read a bool value from an input streamstatic final byte[]
readBytes
(DataInputStream dis) Read a list from an input streamstatic final double
readDouble
(DataInputStream inputStream) Read a double value from an input streamstatic final float
readFloat
(DataInputStream inputStream) Read a float value from an input streamstatic final int
readInt
(InputStream inputStream) Read an int value from an input streamstatic final List
static final List
readList
(DataInputStream dis) Read a list from an input streamstatic final List
readList
(DataInputStream dis, ClassLoader classLoader) Read a list from an input streamstatic final long
readLong
(DataInputStream inputStream) Read a long value from an input streamstatic final Map
readMap
(DataInputStream dis) Read a Map from an input streamstatic final Map
readMap
(DataInputStream dis, ClassLoader loader) Read a Map from an input streamstatic final Object
Currently these data types are supported.static final Object
readObject
(DataInputStream dis, ClassLoader classLoader) Currently these data types are supported.static final short
readShort
(InputStream inputStream) Read an int value from an input streamstatic final String
Read a String from an input streamstatic final <T> void
write
(DataOutputStream out, T object, Class<T> clazz) static final void
writeBool
(OutputStream outputStream, boolean bool) Write a boolean value to an output streamstatic final void
writeBytes
(DataOutputStream dos, byte[] bytes) Write a bytes to an output streamstatic final void
writeDouble
(DataOutputStream outputStream, double value) Write a double value to an output streamstatic final void
writeFloat
(DataOutputStream outputStream, float value) Write a float value to an output streamstatic final void
writeInt
(OutputStream outputStream, int value) Write an int value to an output streamstatic final void
writeIntList
(DataOutputStream dos, List list) static final void
writeList
(DataOutputStream dos, List list) Write a list to an output streamstatic final void
writeLong
(DataOutputStream outputStream, long value) Write a long value to an output streamstatic final void
writeMap
(DataOutputStream dos, Map map) Write a Map to an output streamstatic final void
writeObject
(DataOutputStream dos, Object obValue) When obValue is not supported te be serialized, an IOException will be thrown.static final void
writeRawBytes
(DataOutputStream dos, byte[] bytes) Write a byte array to an output stream only with its raw content.static final void
writeShort
(OutputStream outputStream, short value) Write an int value to an output streamstatic final void
writeString
(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:
IOException
BirtException
-
writeBytes
Write a bytes to an output stream- Parameters:
dos
-dataMap
-- Throws:
IOException
BirtException
-
readList
Read a list from an input stream- Parameters:
dos
-- Returns:
- Throws:
IOException
BirtException
-
readList
Read a list from an input stream- Parameters:
dos
-- Returns:
- Throws:
IOException
BirtException
-
readIntList
- Throws:
IOException
-
writeList
Write a list to an output stream- Parameters:
dos
-dataMap
-- Throws:
IOException
BirtException
-
writeIntList
- Throws:
IOException
-
readMap
Read a Map from an input stream- Parameters:
dos
-- Returns:
- Throws:
IOException
BirtException
-
readMap
Read a Map from an input stream- Parameters:
dos
-- Returns:
- Throws:
IOException
BirtException
-
writeMap
Write a Map to an output stream- Parameters:
dos
-map
-- Throws:
IOException
BirtException
-