+++ /dev/null
-// Copyright (C) 2003 Adam Megacz <adam@ibex.org> all rights reserved.
-//
-// You may modify, copy, and redistribute this code under the terms of
-// the GNU Library Public License version 2.1, with the exception of
-// the portion of clause 6a after the semicolon (aka the "obnoxious
-// relink clause")
-
-package org.ibex.util;
-import java.io.*;
-
-public class InputStreamToByteArray {
-
- /** scratch space for isToByteArray() */
- private static byte[] workspace = new byte[16 * 1024];
-
- /** Trivial method to completely read an InputStream */
- public static synchronized byte[] convert(InputStream is) throws IOException {
- int pos = 0;
- while (true) {
- int numread = is.read(workspace, pos, workspace.length - pos);
- if (numread == -1) break;
- else if (pos + numread < workspace.length) pos += numread;
- else {
- pos += numread;
- byte[] temp = new byte[workspace.length * 2];
- System.arraycopy(workspace, 0, temp, 0, workspace.length);
- workspace = temp;
- }
- }
- byte[] ret = new byte[pos];
- System.arraycopy(workspace, 0, ret, 0, pos);
- return ret;
- }
-
-}