All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.co.autotrader.traverson.conversion.ByteArrayConverter Maven / Gradle / Ivy

Go to download

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 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);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy