uk.co.autotrader.traverson.conversion.ByteArrayConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of traverson4j-core Show documentation
Show all versions of traverson4j-core Show documentation
The kernel of traverson4j. This provides the main API for a client to traverse a Hypermedia REST service
The newest version!
package uk.co.autotrader.traverson.conversion;
import uk.co.autotrader.traverson.exception.ConversionException;
import java.io.IOException;
import java.io.InputStream;
class ByteArrayConverter implements ResourceConverter {
@Override
public Class getDestinationType() {
return byte[].class;
}
@Override
public byte[] convert(InputStream resource, Class extends byte[]> returnType) {
try (InputStream streamToProcess = resource) {
return streamToProcess.readAllBytes();
} catch (IOException e) {
throw new ConversionException("Failed to convert the input stream to a byte array", null, e);
}
}
}