MCPcopy Index your code
hub / github.com/clojure/clojure / readStream

Method readStream

src/jvm/clojure/asm/ClassReader.java:297–316  ·  view source on GitHub ↗

Reads the given input stream and returns its content as a byte array. @param inputStream an input stream. @param close true to close the input stream after reading. @return the content of the given input stream. @throws IOException if a problem occurs during reading.

(final InputStream inputStream, final boolean close)

Source from the content-addressed store, hash-verified

295 * @throws IOException if a problem occurs during reading.
296 */
297 private static byte[] readStream(final InputStream inputStream, final boolean close)
298 throws IOException {
299 if (inputStream == null) {
300 throw new IOException("Class not found");
301 }
302 try {
303 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
304 byte[] data = new byte[INPUT_STREAM_DATA_CHUNK_SIZE];
305 int bytesRead;
306 while ((bytesRead = inputStream.read(data, 0, data.length)) != -1) {
307 outputStream.write(data, 0, bytesRead);
308 }
309 outputStream.flush();
310 return outputStream.toByteArray();
311 } finally {
312 if (close) {
313 inputStream.close();
314 }
315 }
316 }
317
318 // -----------------------------------------------------------------------------------------------
319 // Accessors

Callers 1

ClassReaderMethod · 0.95

Calls 3

writeMethod · 0.80
toByteArrayMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected