1 StringBuilder textBuilder = new StringBuilder();
2 try (Reader reader = new BufferedReader(new InputStreamReader
3 (stream, Charset.forName(StandardCharsets.UTF_8.name())))) {
4 int c = 0;
5 while ((c = reader.read()) != -1) {
6 textBuilder.append((char) c);
7 }
8 } catch (IOException e) {
9 e.printStackTrace();
10 }
11 textBuilder.toString;
1 Scanner s = new Scanner(inputStream).useDelimiter("\\A");
2 String result = s.hasNext() ? s.next() : "";
3