源代码1:
InputStream in = new FileInputStream("E:\\java编程思想.jpg");
byte[] data = new byte[in.available()];
in.read(data);
源代码2:
InputStream in = new FileInputStream("E:\\java编程思想.jpg");
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] data = null;
byte[] buf = new byte[1024];
int numBytesRead = 0;
while ((numBytesRead = in.read(buf)) != -1) {
output.write(buf, 0, numBytesRead);
}
data = output.toByteArray();
以上两个程序有什么性能上的区别吗?
翻阅古今
翻过高山走不出你