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) 

Source Link

Document

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

Usage

From source file:com.spectralogic.ds3client.MockedWebResponse.java

public MockedWebResponse(final String responseString, final int statusCode, final Map<String, String> headers) {
    this.responseStream = IOUtils.toInputStream(responseString);
    this.statusCode = statusCode;
    this.headers = new MockedHeaders(headers);
}

From source file:de.tor.tribes.util.xml.JDomUtils.java

public static Document getOldDocument(InputStream inStream) throws Exception {
    InputStream s1 = IOUtils.toInputStream("<data>");
    InputStream s2 = IOUtils.toInputStream("</data>");
    return getDocument(new java.io.SequenceInputStream(new java.io.SequenceInputStream(s1, inStream), s2));
}

From source file:com.github.thesmartenergy.sparql.generate.api.UniqueLocator.java

@Override
public TypedStream open(String messageuri) {
    if (messageuri.equals(this.messageuri)) {
        return new TypedStream(IOUtils.toInputStream(message), datatype);
    } else {/*ww w  .ja  va2 s.c o  m*/
        return null;
    }
}

From source file:com.allogy.couch.importers.command.BufferedImportCommandTest.java

@Before
public void setUp() {
    innerImportCommand = mock(ImportCommand.class);
    innerDataStream = UUID.randomUUID().toString();
    stub(innerImportCommand.getDataStream()).toReturn(IOUtils.toInputStream(innerDataStream));
}

From source file:mobi.jenkinsci.model.RawBinaryNode.java

@Override
public InputStream getDownloadedObjectData() {
    if (data == null) {
        return null;
    }//  w  ww . j a  va 2s  . c o m

    if (data instanceof InputStream) {
        return (InputStream) data;
    } else if (data instanceof String) {
        return IOUtils.toInputStream((String) data);
    } else if (data instanceof byte[]) {
        return new ByteArrayInputStream((byte[]) data);
    } else {
        log.error("Invalid data object type for serialisation: " + data.getClass());
        return null;
    }
}

From source file:com.leclercb.commons.api.license.License.java

public static License parseLicense(String license) throws Exception {
    PropertyMap p = new PropertyMap();
    p.load(IOUtils.toInputStream(license));

    License l = new License();
    l.setProperties(p);/*from   www .  ja v a  2 s  .  co m*/

    return l;
}

From source file:br.ufg.inf.es.fs.contpatri.persistencia.JsonUtil.java

public InputStream deJsonParaInputStream(Object objeto) throws IOException {
    String json = gson.toJson(objeto);

    InputStream is = IOUtils.toInputStream(json);

    return is;//from  w w  w.j ava2  s  .c  o  m
}

From source file:com.allogy.io.BulkUpdateInputStreamTest.java

@Before
public void setUp() {
    innerStrings = new ArrayList<String>();
    innerInputStreams = new ArrayList<InputStream>();
    for (int i = 0; i < 3; i++) {
        String string = UUID.randomUUID().toString();
        innerStrings.add(string);/*from   ww w  .  j a  v  a2s  .c  o  m*/
        innerInputStreams.add(IOUtils.toInputStream("\"" + string + "\""));
    }
}

From source file:com.collective.celos.ci.testing.fixtures.convert.FixTableToTSVFileConverter.java

@Override
public FixFile convert(TestRun tr, FixTable table) throws Exception {
    List<String> lines = new ArrayList<>();
    for (FixTable.FixRow row : table.getRows()) {
        lines.add(StringUtils.join(row.getOrderedColumns(table.getColumnNames()), "\t"));
    }/*from  w  ww  .  j a v  a2  s. co  m*/
    return new FixFile(IOUtils.toInputStream(StringUtils.join(lines, "\n") + "\n"));
}

From source file:de.catma.serialization.tei.pointer.TextFragmentIdentifierFactory.java

public TextFragmentIdentifier createTextFragmentIdentifier(String fragmentIdentifier)
        throws RecognitionException {
    ANTLRInputStream is;/*from   www .  j ava 2 s.  c o  m*/
    try {
        is = new ANTLRInputStream(IOUtils.toInputStream(fragmentIdentifier));
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
    URIFragmentIdentifierPlainTextLexer lexer = new URIFragmentIdentifierPlainTextLexer(is);
    CommonTokenStream ts = new CommonTokenStream(lexer);
    URIFragmentIdentifierPlainTextParser parser = new URIFragmentIdentifierPlainTextParser(ts);
    parser.start();
    return parser.getTextFragmentIdentifier();

}