Beliebte Suchanfragen

Cloud Native

DevOps

IT-Security

Agile Methoden

Java

|
//

Convert InputStream to String

10.8.2009 | 1 minutes of reading time

Because searching for “Convert InputStream to String” still brings up solutions involving StringBuffer, byte[] or something like that, developers still produce large amounts of different implementations of the same conversion in their projects. In an attempt to reduce the variations here the simplest solution using no custom code at all:

1InputStream stream = getClass().getResourceAsStream("/classpath/resource.xml");
2 String xml = org.apache.commons.io.IOUtils.toString(stream);

Please spread the word, use apache commons 🙂

|

share post

Likes

0

//

More articles in this subject area

Discover exciting further topics and let the codecentric world inspire you.

//

Gemeinsam bessere Projekte umsetzen.

Wir helfen deinem Unternehmen.

Du stehst vor einer großen IT-Herausforderung? Wir sorgen für eine maßgeschneiderte Unterstützung. Informiere dich jetzt.

Hilf uns, noch besser zu werden.

Wir sind immer auf der Suche nach neuen Talenten. Auch für dich ist die passende Stelle dabei.