Example usage for org.apache.commons.io IOUtils toInputStream

List of usage examples for org.apache.commons.io IOUtils toInputStream

Introduction

In this page you can find the example usage for org.apache.commons.io IOUtils toInputStream.

Prototype

public static InputStream toInputStream(String input, String encoding) throws IOException 

Source Link

Document

Convert the specified string to an input stream, encoded as bytes using the specified character encoding.

Usage

From source file:ingest.inspect.GeoJsonInspector.java

/**
 * Gets the Input Stream for a GeoJSON Resource
 * /* ww  w. ja v  a  2s  . co  m*/
 * @param dataResource
 *            data resource to pull input stream from
 * @return File object
 */
private InputStream getGeoJsonInputStream(DataResource dataResource)
        throws IOException, AmazonClientException, InvalidInputException {
    FileAccessFactory fileFactory = ingestUtilities.getFileFactoryForDataResource(dataResource);
    InputStream inputStream;

    if (((GeoJsonDataType) dataResource.getDataType()).getLocation() != null) {
        inputStream = fileFactory.getFile(((GeoJsonDataType) dataResource.getDataType()).getLocation());
    } else {
        String geoJsonContent = ((GeoJsonDataType) dataResource.getDataType()).getGeoJsonContent();
        inputStream = IOUtils.toInputStream(geoJsonContent, "UTF-8");
    }

    return inputStream;
}