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:com.izforge.izpack.uninstaller.resource.InstallLogTest.java

/**
 * Sets up the test case.//from  w  ww. ja  v a 2 s.c  o  m
 *
 * @throws IOException for any I/O error
 */
@Before
public void setUp() throws IOException {
    // set up a mock resource
    String installLog = "myapp\n" + "myapp/dir2/dir3\n" + "myapp/dir2/dir3/file2\n" + "myapp/dir2/file1\n"
            + "myapp/dir1\n";
    StringReader reader = new StringReader(installLog);
    resources = Mockito.mock(Resources.class);
    when(resources.getInputStream("install.log")).thenReturn(new ReaderInputStream(reader));
}

From source file:com.ibm.jaggr.core.resource.StringResource.java

@Override
public InputStream getInputStream() throws IOException {
    return new ReaderInputStream(getReader());
}

From source file:cn.liutils.cgui.loader.xml.CGUIDocLoader.java

public LIGui loadXml(String xml) throws Exception {
    return loadXml(new ReaderInputStream(new StringReader(xml)));
}

From source file:hugonicolau.openbrailleinput.wordcorrection.mafsa.MAFSA.java

/**
 * Factory method.  Creates a new Dawg entry by reading in data from the given Reader.  Once the data is read, the
 * reader remains open./*from w  w w. j  ava  2 s. c o  m*/
 *
 * @param reader the reader with the data to create the Dawg instance
 * @return a new Dawg instance with the data loaded
 * @throws DataFormatException if the Reader doesn't contain the proper data format for loading a Dawg instance
 * @throws IOException if reading from the Reader causes an IOException
 */
public static MAFSA load(Reader reader) throws IOException {
    return load(new ReaderInputStream(reader));
}

From source file:com.quartercode.disconnected.test.profile.ProfileSerializerTest.java

@Test
public void testSerializeEquals() throws IOException, JAXBException {

    StringWriter serialized = new StringWriter();
    WriterOutputStream outputStream = new WriterOutputStream(serialized);
    ProfileSerializer.serialize(outputStream, simulation);
    outputStream.close();/*  ww w  .j av a2 s.c  o m*/

    Simulation copy = ProfileSerializer
            .deserialize(new ReaderInputStream(new StringReader(serialized.toString())));
    Assert.assertEquals("Simulation equals serialized-deserialized copy", simulation, copy);
}

From source file:com.icantrap.collections.dawg.Dawg.java

/**
 * Factory method.  Creates a new Dawg entry by reading in data from the given Reader.  Once the data is read, the
 * reader remains open./*  w  w w  . j  a  va2s  .  co m*/
 *
 * @param reader the reader with the data to create the Dawg instance
 * @return a new Dawg instance with the data loaded
 * @throws DataFormatException if the Reader doesn't contain the proper data format for loading a Dawg instance
 * @throws IOException if reading from the Reader causes an IOException
 */
public static Dawg load(Reader reader) throws IOException {
    return load(new ReaderInputStream(reader));
}

From source file:com.pnf.plugin.pdf.XFAParser.java

public void parse(byte[] xmlContent) throws ParserConfigurationException, SAXException, IOException {
    CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder();
    decoder.onMalformedInput(CodingErrorAction.REPLACE);
    decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
    CharBuffer parsed = decoder.decode(ByteBuffer.wrap(xmlContent));

    SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser parser = factory.newSAXParser();

    try (@SuppressWarnings("deprecation")
    InputStream is = new ReaderInputStream(new CharArrayReader(parsed.array()))) {
        parser.parse(is, xfa);//from  w  w w.  j a v a2  s . c om
    } catch (Exception e) {
        logger.catching(e);
        logger.error("Error while parsing XFA content");
    }
}

From source file:com.github.rwitzel.streamflyer.support.ProcessEndOfStreamTest.java

/**
 * @param flush// w  w  w.j  a v a2s .  c  om
 * @return Returns true if the actual output is equals to the expected
 *         output.
 * @throws Exception
 */
private boolean rewriteContent(boolean flush, String domainPrefix) throws Exception {
    String contentPart = StringUtils.repeat("text", 2);
    String oldUrl = domainPrefix + "something";
    String expectedNewUrl = domainPrefix + "anything";
    String oldHtml = "<html><body>" + contentPart + oldUrl + contentPart + "</body></html>";
    String expectedNewHtml = "<html><body>" + contentPart + expectedNewUrl + contentPart + "</body></html>";
    String encoding = "UTF-8";

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    long written = rewriteContent(new ReaderInputStream(new StringReader(oldHtml)), os, encoding, flush);
    System.out.println("written: " + written);
    System.out.println("oldHtml.length(): " + oldHtml.length());
    System.out.println("expectedNewHtml.length(): " + expectedNewHtml.length());
    System.out.println("expectedNewHtml: \n" + expectedNewHtml);
    os.flush();
    String newHtml = new String(os.toByteArray(), encoding);
    System.out.println(newHtml);
    return expectedNewHtml.equals(newHtml);
}

From source file:com.bigdata.rdf.rio.json.BigdataSPARQLResultsJSONParserForConstruct.java

@Override
public void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
    parse(new ReaderInputStream(reader), baseURI);
}

From source file:com.btmatthews.jcrunit.JCRRepositoryRule.java

public JCRRepositoryRule createFile(final String path, final String name, final String type,
        final String encoding, final String data) throws IOException, RepositoryException {
    try (final InputStream inputStream = new ReaderInputStream(new StringReader(data))) {
        return createFile(path, name, type, encoding, inputStream);
    }/* w  w w .  j  av  a  2s .  co m*/
}