public static byte[] readAsByteArray(InputStream input) throws IOException {
byte[] bytes = new byte[input.available()];
try{
input.read(bytes);
}catch(IOException e){
System.out.println("ERROR");
}
return bytes;
}
大家看下这样读取输入流的数据对不对,和其它IO流的使用方式比较 有什么不足的地方?
欢迎大家给出意见
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
小文件还好,大文件当心内存问题呀
你这样写,缓冲器可能超过内存大小,如果流很大的话。
byte[] bytes=new byte[input.available]创建的缓冲区可能超过内存大小