黑马程序员技术交流社区
标题:
关于文件分割和和合并中的小问题
[打印本页]
作者:
草鱼狂飙
时间:
2014-5-6 17:24
标题:
关于文件分割和和合并中的小问题
这是我的代码
private static void splitFile() throws Exception {
// TODO Auto-generated method stub
FileInputStream fis = new FileInputStream("d:\\1.mp3");
FileOutputStream fos = null;
byte[] by = new byte[1204 * 1024];
int len;
int count = 0;
while ((len = fis.read(by)) != -1) {
fos = new FileOutputStream("d:\\splitfile" + (count++) + ".part");
fos.write(by);//look!here ,here
fos.close();
}
}
复制代码
其中的fos.write(by)和老师视频中的代码fos.write(by,0,len)在理论中有什么区别?
作者:
曹冬明
时间:
2014-5-6 17:54
比如数组中你只读到一个字节,数组也就没满,你确把整个数组都写进去了,这就是区别啊
作者:
skill20
时间:
2014-5-6 17:56
区别在数组长度。
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2