package Tools;

import java.io.*;

/**
 * Copy an InputStream to an OutputStream. This while() loop idiom seems
 * to turn up enough that it belongs in a Tools method.
 */
public class CopyStream {
	public static void copyStream(InputStream is, OutputStream os)
		throws IOException {
		copyStream(is, os, 8192);
	}

	public static void copyStream(InputStream is, OutputStream os, int bufSize)
		throws IOException {
		byte[] buf = new byte[bufSize];
		int rc;

		while ((rc=is.read(buf))>0) {
			os.write(buf, 0, rc);
		}
	}
}
