Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String convertInputStreamToString(InputStream inputStream) {
- try {
- int chunkSize = 128;
- byte[] bytes = new byte[chunkSize];
- ByteArrayOutputStream baos = new ByteArrayOutputStream(chunkSize);
- int bytesRead;
- do {
- bytesRead = inputStream.read(bytes, 0, chunkSize);
- if (bytesRead == -1) break;
- baos.write(bytes, 0, bytesRead);
- } while (true);
- return baos.toString("UTF-8");
- } catch (IOException ex) {
- Logger.getLogger(InputStreamToString.class.getName()).log(Level.SEVERE, null, ex);
- return "";
- }
- }
Add Comment
Please, Sign In to add comment