怎么在jsp里面读取一个wav文件并生成一个新的文件??
ReadBuf.java文件(一个javabean负责读取一个wav文件)
public class ReadBuf {
public ReadBuf() {
}
public byte[] getFileWithBytes(String fileName) {
byte[] readBytes = new byte[10000];
try {
File file = new File(fileName);
if (!file.exists()) {
throw new Exception("file does not exists");
}
InputStream is = new FileInputStream(file);
BufferedInputStream bs = new BufferedInputStream(is);
bs.read(readBytes);
} catch (Exception ex) {
}
return readBytes;
}
}
read.jsp(负责读取并生成一个read.wav的文件)
<%@ page contentType="audio/x-wav"%>
<%@ page import="com.pm.test.*"%>
<%
ReadBuf rb = new ReadBuf();
out.print(rb.getFileWithBytes("D:\\WindowsXP.wav"));
%>
问题:
为什么读取到的read.wav文件不能播放(格式错误了)????????