storagehub-client-wrapper/src/main/java/org/gcube/common/storagehubwrapper/server/WrapperUtility.java

46 lines
749 B
Java

/**
*
*/
package org.gcube.common.storagehubwrapper.server;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Oct 17, 2018
*/
public class WrapperUtility {
/**
* To input stream.
*
* @param content the content
* @return the input stream
*/
public static InputStream toInputStream(byte[] content) {
int size = content.length;
InputStream is = null;
byte[] b = new byte[size];
try {
is = new ByteArrayInputStream(content);
is.read(b);
return is;
}
catch (IOException e) {
return null;
}
finally {
try {
if (is != null)
is.close();
}
catch (Exception ex) {
}
}
}
}