Esempio n. 1
0
 private String read(Reader in) throws IOException {
   StringBuilder builder = new StringBuilder();
   char[] buffer = new char[1048];
   while (true) {
     int nBytes = in.read(buffer);
     if (nBytes == -1) break;
     builder.append(new String(buffer, 0, nBytes));
   }
   return builder.toString();
 }
Esempio n. 2
0
 private String stream(InputStream inputStream) throws IOException {
   BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
   StringBuilder stringBuilder = new StringBuilder();
   String line;
   while ((line = bufferedReader.readLine()) != null) {
     stringBuilder.append(line).append("\n");
   }
   bufferedReader.close();
   return stringBuilder.toString();
 }