Java: convert inputStream to String

easy.

private String inputStreamToString(InputStream in) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in));
StringBuilder stringBuilder = new StringBuilder();
String line = null;

while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line + „\n“);
}

bufferedReader.close();
return stringBuilder.toString();
}

Advertisements

Die Kommentarfunktion ist geschlossen.