FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(new File(src)); // 建立文件输入流
fos = new FileOutputStream(to);
byte[] buffer = new byte[1024];
int len;
while ((len = fis.read(buffer)) != -1){
fos.write(buffer, 0, len);
}
}
new byte[1024];这里这个大小指定的依据是什么?1024是个什么概念(1024byte=128字节)
这个文件最大就只能放128个字节的内容 ?还是说超过了会自动增长???
FileOutputStream fos = null;
try {
fis = new FileInputStream(new File(src)); // 建立文件输入流
fos = new FileOutputStream(to);
byte[] buffer = new byte[1024];
int len;
while ((len = fis.read(buffer)) != -1){
fos.write(buffer, 0, len);
}
}
new byte[1024];这里这个大小指定的依据是什么?1024是个什么概念(1024byte=128字节)
这个文件最大就只能放128个字节的内容 ?还是说超过了会自动增长???
len = fis.read(buffer)
尝试将buffer大小(此为1024)位数据读入buffer内,返回值len为实际读的长度,如果读满就是1024,如果待读的长度不足1024则为实际读出的数量另外啊,这里不是有while么,这是循环读取,每次最多读1024