Package org.gcube.common.gxhttp.util
Class ContentUtils
- java.lang.Object
-
- org.gcube.common.gxhttp.util.ContentUtils
-
public final class ContentUtils extends Object
Manipulation of a response's content.- Author:
- Manuele Simi (ISTI CNR)
-
-
Constructor Summary
Constructors Constructor Description ContentUtils()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static byte[]toByteArray(InputStream input)Gets the contents of anInputStreamas abyte[].static byte[]toByteArray(Object obj)Converts an object to an array of bytesObjecttoObject(byte[] data)Converts the array of bytes into an object.static <T> TtoObject(InputStream inputStream, Class<T> class1)static StringtoString(byte[] bytes)
-
-
-
Method Detail
-
toByteArray
public static byte[] toByteArray(Object obj) throws IOException
Converts an object to an array of bytes- Parameters:
obj-- Returns:
- the bytes
- Throws:
IOException
-
toObject
public static <T> T toObject(InputStream inputStream, Class<T> class1) throws IOException, ClassNotFoundException
- Parameters:
inputStream-class1-- Returns:
- an instance of type "type"
- Throws:
IOExceptionClassNotFoundException
-
toObject
public Object toObject(byte[] data) throws IOException, ClassNotFoundException
Converts the array of bytes into an object.- Parameters:
data-- Returns:
- the object
- Throws:
IOExceptionClassNotFoundException
-
toByteArray
public static byte[] toByteArray(InputStream input) throws IOException
Gets the contents of anInputStreamas abyte[].- Parameters:
input- theInputStreamto read from- Returns:
- the requested byte array
- Throws:
NullPointerException- if the input is nullIOException- if an I/O error occurs
-
toString
public static String toString(byte[] bytes)
- Parameters:
bytes-- Returns:
- the string
-
-