Example usage for org.apache.commons.io.input ReaderInputStream ReaderInputStream

List of usage examples for org.apache.commons.io.input ReaderInputStream ReaderInputStream

Introduction

In this page you can find the example usage for org.apache.commons.io.input ReaderInputStream ReaderInputStream.

Prototype

public ReaderInputStream(Reader reader) 

Source Link

Document

Construct a new ReaderInputStream that uses the default character encoding with a default input buffer size of 1024 characters.

Usage

From source file:org.apache.ambari.view.hive.resources.uploads.UploadService.java

private String uploadIntoTable(Reader reader, String databaseName, String tempTableName) {
    try {/*from  w  w  w .  j a  v a  2s .c o  m*/
        String basePath = getHiveMetaStoreLocation();

        if (!basePath.endsWith("/")) {
            basePath = basePath + "/";
        }

        if (databaseName != null && !databaseName.equals(HIVE_DEFAULT_DB)) {
            basePath = basePath + databaseName + ".db/";
        }

        String fullPath = basePath + tempTableName + "/" + tempTableName + ".csv";

        LOG.info("Uploading file into : {}", fullPath);

        uploadFile(fullPath, new ReaderInputStream(reader));

        return fullPath;
    } catch (Exception e) {
        throw new ServiceFormattedException(e.getMessage(), e);
    }
}

From source file:org.apache.hadoop.gateway.filter.rewrite.impl.form.FormUrlRewriteStreamFilter.java

@Override
public InputStream filter(InputStream stream, String encoding, UrlRewriter rewriter, Resolver resolver,
        UrlRewriter.Direction direction, UrlRewriteFilterContentDescriptor config) throws IOException {
    return new ReaderInputStream(new FormUrlRewriteFilterReader(new InputStreamReader(stream, encoding),
            rewriter, resolver, direction, config));
}

From source file:org.apache.hadoop.gateway.filter.rewrite.impl.html.HtmlUrlRewriteStreamFilter.java

@Override
public InputStream filter(InputStream stream, String encoding, UrlRewriter rewriter, Resolver resolver,
        UrlRewriter.Direction direction, UrlRewriteFilterContentDescriptor config) throws IOException {
    try {//from  w  ww  .  j a  va  2  s .c  o  m
        return new ReaderInputStream(new HtmlUrlRewriteFilterReader(new InputStreamReader(stream, encoding),
                rewriter, resolver, direction, config));
    } catch (ParserConfigurationException e) {
        throw new IOException(e);
    }
}

From source file:org.apache.hadoop.gateway.filter.rewrite.impl.json.JsonUrlRewriteStreamFilter.java

@Override
public InputStream filter(InputStream stream, String encoding, UrlRewriter rewriter, Resolver resolver,
        UrlRewriter.Direction direction, UrlRewriteFilterContentDescriptor config) throws IOException {
    return new ReaderInputStream(new JsonUrlRewriteFilterReader(new InputStreamReader(stream, encoding),
            rewriter, resolver, direction, config));
}

From source file:org.apache.hadoop.gateway.filter.rewrite.impl.xml.XmlUrlRewriteStreamFilter.java

@Override
public InputStream filter(InputStream stream, String encoding, UrlRewriter rewriter, Resolver resolver,
        UrlRewriter.Direction direction, UrlRewriteFilterContentDescriptor config) throws IOException {
    try {/* w w  w . ja v a  2s.  c om*/
        return new ReaderInputStream(new XmlUrlRewriteFilterReader(new InputStreamReader(stream, encoding),
                rewriter, resolver, direction, config));
    } catch (ParserConfigurationException e) {
        throw new IOException(e);
    } catch (XMLStreamException e) {
        throw new IOException(e);
    }
}

From source file:org.apache.samza.webapp.TestApplicationMasterRestClient.java

private void setupMockClientResponse(int statusCode, String statusReason, String responseBody)
        throws IOException {
    StatusLine statusLine = mock(StatusLine.class);
    when(statusLine.getStatusCode()).thenReturn(statusCode);
    when(statusLine.getReasonPhrase()).thenReturn(statusReason);

    HttpEntity entity = mock(HttpEntity.class);
    when(entity.getContent()).thenReturn(new ReaderInputStream(new StringReader(responseBody)));

    CloseableHttpResponse response = mock(CloseableHttpResponse.class);
    when(response.getStatusLine()).thenReturn(statusLine);
    when(response.getEntity()).thenReturn(entity);

    when(mockClient.execute(any(HttpHost.class), any(HttpGet.class))).thenReturn(response);
}

From source file:org.culturegraph.mf.stream.source.TarReader.java

@Override
public void process(final Reader reader) {
    TarArchiveInputStream tarInputStream = null;
    try {/*from www .  ja  v a  2 s  .  c om*/
        tarInputStream = new TarArchiveInputStream(new ReaderInputStream(reader));
        TarArchiveEntry entry = null;
        while ((entry = (TarArchiveEntry) tarInputStream.getNextEntry()) != null) {
            if (!entry.isDirectory()) {
                final byte[] buffer = new byte[(int) entry.getSize()];
                while ((tarInputStream.read(buffer)) > 0) {
                    getReceiver().process(new StringReader(new String(buffer)));
                }
            }
        }
        tarInputStream.close();
    } catch (final FileNotFoundException e) {
        e.printStackTrace();
    } catch (final IOException e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(tarInputStream);
    }
}

From source file:org.dspace.ctask.mediafilter.ExtractText.java

@Override
protected boolean filterBitstream(Item item, Bitstream bitstream)
        throws AuthorizeException, IOException, SQLException {
    return createDerivative(item, bitstream,
            new ReaderInputStream(new ParsingReader(teParser, bitstream.retrieve(), new Metadata(), pctx)));
}

From source file:org.eclipse.sw360.licenseinfo.parsers.CLIParserTest.java

@Test
public void testIsApplicableTo() throws Exception {
    when(connector.getAttachmentStream(eq(content), anyObject(), anyObject()))
            .thenReturn(new ReaderInputStream(new StringReader(CLI_TESTFILE)));
    assertTrue(parser.isApplicableTo(attachment, new User(), new Project()));
}

From source file:org.eclipse.sw360.licenseinfo.parsers.CLIParserTest.java

@Test
public void testIsApplicableToFailsOnIncorrectRootElement() throws Exception {
    AttachmentContent content = new AttachmentContent().setId("A1").setFilename("a.xml")
            .setContentType("application/xml");
    when(connector.getAttachmentStream(eq(content), anyObject(), anyObject()))
            .thenReturn(new ReaderInputStream(new StringReader("<wrong-root/>")));
    assertFalse(parser.isApplicableTo(attachment, new User(), new Project()));
}