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文件是可以正常播放完的