If you think the Android project USBIPServerForAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package org.cgutman.usbip.utils;
/*www.java2s.com*/import java.io.IOException;
import java.io.InputStream;
publicclass StreamUtils {
publicstaticvoid readAll(InputStream in, byte[] buffer) throws IOException {
readAll(in, buffer, 0, buffer.length);
}
publicstaticvoid readAll(InputStream in, byte[] buffer, int offset, int length) throws IOException {
int i = 0;
while (i < length) {
int ret = in.read(buffer, offset+i, length-i);
if (ret <= 0) {
thrownew IOException("Read failed: "+ret);
}
i += ret;
}
}
}