com.google.sitebricks.client.transport.ByteArrayTransport Maven / Gradle / Ivy
package com.google.sitebricks.client.transport;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* @author Dhanji R. Prasanna ([email protected])
*/
class ByteArrayTransport extends Raw {
@SuppressWarnings("unchecked")
public T in(InputStream in, Class type) throws IOException {
assert type == byte[].class;
return (T) IOUtils.toByteArray(in);
}
public void out(OutputStream out, Class type, T data) throws IOException {
assert data instanceof byte[];
out.write((byte[]) data);
}
}