| 182 | } |
| 183 | |
| 184 | private static String streamToString(InputStream inputStream, String encoding) { |
| 185 | String resultString = null; |
| 186 | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
| 187 | int len; |
| 188 | byte[] data = new byte[1024]; |
| 189 | |
| 190 | try { |
| 191 | while((len = inputStream.read(data)) != -1) { |
| 192 | byteArrayOutputStream.write(data, 0, len); |
| 193 | } |
| 194 | if(encoding.equals("")) { |
| 195 | encoding = "UTF-8"; |
| 196 | } |
| 197 | resultString = byteArrayOutputStream.toString(encoding); |
| 198 | } catch (IOException var6) { |
| 199 | resultString = var6.getMessage(); |
| 200 | // var6.printStackTrace(); |
| 201 | LOGGER.error(var6.getMessage()); |
| 202 | |
| 203 | } |
| 204 | |
| 205 | return resultString; |
| 206 | } |
| 207 | } |
| 208 | |