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

uk.co.autotrader.traverson.conversion.StringResourceConverter 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;
import java.nio.charset.StandardCharsets;

class StringResourceConverter implements ResourceConverter {

    @Override
    public Class getDestinationType() {
        return String.class;
    }

    @Override
    public String convert(InputStream resource, Class returnType) {
        try (InputStream streamToProcess = resource) {
            return new String(streamToProcess.readAllBytes(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new ConversionException("Failed to convert the input stream to a string", null, e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy