Package com.academy.utils
Class TransferUtil
- java.lang.Object
-
- com.academy.utils.TransferUtil
-
public class TransferUtil extends java.lang.ObjectTransfer object utilities Includes various methods for object serialization/deserialization- Author:
- Ruslan Nazirov
-
-
Constructor Summary
Constructors Constructor Description TransferUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]compress(byte[] data)Compress selected serialized datastatic byte[]decompress(byte[] compressedData)Deserialize selected compressed datastatic java.lang.ObjectdecompressAndDecerialize(byte[] data)Decompress and deserialize selected datastatic java.lang.Objectdeserialize(byte[] data)Deserialize selected serialized datastatic byte[]serialize(java.lang.Object object)Serialize selected objectstatic byte[]serializeAndCompress(java.lang.Object object)Serialize and compress selected objectstatic java.util.HashMap<java.util.zip.ZipEntry,java.io.ByteArrayOutputStream>unzip(int bufferSize, java.lang.String zipExtension, java.io.ByteArrayOutputStream zippedFileOS)Unzip archive on file system and get it content to operate
-
-
-
Method Detail
-
serializeAndCompress
public static byte[] serializeAndCompress(java.lang.Object object) throws java.lang.ExceptionSerialize and compress selected object- Parameters:
object- Object to operate- Returns:
- Serialized and compressed data or null if error happened
- Throws:
java.lang.Exception- exception, which happened during this method execution
-
decompressAndDecerialize
public static java.lang.Object decompressAndDecerialize(byte[] data) throws java.lang.ExceptionDecompress and deserialize selected data- Parameters:
data- Compressed and serialized data- Returns:
- Decompressed and deserialized object or null if error happened
- Throws:
java.lang.Exception- exception, which happened during this method execution
-
serialize
public static byte[] serialize(java.lang.Object object) throws java.lang.ExceptionSerialize selected object- Parameters:
object- Object to serialize- Returns:
- Serialized data
- Throws:
java.lang.Exception- exception, which happened during this method execution
-
compress
public static byte[] compress(byte[] data) throws java.lang.ExceptionCompress selected serialized data- Parameters:
data- Serialized data- Returns:
- Compressed data
- Throws:
java.lang.Exception- exception, which happened during this method execution
-
deserialize
public static java.lang.Object deserialize(byte[] data) throws java.lang.ExceptionDeserialize selected serialized data- Parameters:
data- Serialized data- Returns:
- Original object
- Throws:
java.lang.Exception- exception, which happened during this method execution
-
unzip
public static java.util.HashMap<java.util.zip.ZipEntry,java.io.ByteArrayOutputStream> unzip(int bufferSize, java.lang.String zipExtension, java.io.ByteArrayOutputStream zippedFileOS)Unzip archive on file system and get it content to operate- Parameters:
bufferSize- size of the bufferzipExtension- extension of zipped archives to search archives inside archivezippedFileOS- zip archive file via ByteArrayOutputStream- Returns:
- HashMap with ZipEntry and ByteArrayOutputStream, which allows you to access files inside zip archive
-
decompress
public static byte[] decompress(byte[] compressedData) throws java.lang.ExceptionDeserialize selected compressed data- Parameters:
compressedData- Compressed Data- Returns:
- Decompressed Data
- Throws:
java.lang.Exception- exception, which happened during this method execution
-
-