问题描述
public class App {
public static void readSome(InputStream in) throws IOException {
ByteArrayInputStream is = new ByteArrayInputStream(in.readAllBytes());
is.read(); // variable number of non blocking reads
is.read();
is.read();
in = is; // this does nothing
}
public static void main(String[] args) throws IOException {
ByteArrayInputStream a = new ByteArrayInputStream(new byte[]{1,2,3,4,5,6});
App.readSome(a);
//something
App.readSome(a); // should read 4,6
}
}
是否可以更改readSome
方法中的代码,以使main能够读取所有值,而readSome完成非阻塞读取?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)