| 294 | } |
| 295 | |
| 296 | public static String readReader(Reader reader) throws IOException { |
| 297 | try (BufferedReader in = new BufferedReader(reader)) { |
| 298 | char[] cbuf = new char[1024]; |
| 299 | StringBuilder sb = new StringBuilder(1024); |
| 300 | int bytes_read; |
| 301 | while ((bytes_read = in.read(cbuf, 0, 1024)) != -1) { |
| 302 | sb.append(cbuf, 0, bytes_read); |
| 303 | } |
| 304 | return sb.toString(); |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | public static byte[] readStream(InputStream is, int initialBufferCapacity) throws IOException { |
| 309 | if (initialBufferCapacity <= 0) { |