梧桐初恋
2017-12-21 07:13这个有时候读取文件为什么会断流? while 到一半就断了
5 response.setHeader("Content-Type", "audio/mp3");
File file = new File(localhost_dir);
int len_l = (int) file.length();
byte[] buf = new byte[4096];
FileInputStream fis = new FileInputStream(file);
OutputStream out = response.getOutputStream();
len_l = fis.read(buf);
while (len_l != -1) {
out.write(buf, 0, len_l);
len_l = fis.read(buf);
}
这个有时候读取文件为什么会断流? while 到一半就断了
但是mp3文件是可以正常播放完的
- 点赞
- 回答
- 收藏
- 复制链接分享
6条回答
为你推荐
- 为什么这个地方会有读取访问权限冲突?
- c语言
- c++
- 2个回答
- Qt中使用QDataStream浮点数写入二进制文件中为什么不是4个字节,应该如何写?
- c++
- 1个回答
- 用eof()判断文件是否结束,为什么有的文本文件能判断出来跳出while循环,有的跳不出while循环?
- c语言
- c++
- 1个回答
- 从txt文件中读取数据存入到链表,即使文件没有内容也会存上数字和乱码
- c语言
- 开发语言
- 1个回答
- c++循环语句while中为什么无法使用cin>>语句进行循环输入?
- c++
- 2个回答
换一换