if(req.getContentLength()>297){
bufferedInputStream =new BufferedInputStream(req.getInputStream());
}
File outputFile = new File(path + fileName);
bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(outputFile));
byte[] bytes = new byte[1024];
int count = 0;
System.out.println( bufferedInputStream.read(bytes));
// while ((count = bufferedInputStream.readLine(bytes,0,bytes.length)) > 0)
// while ((count = bufferedInputStream.read(bytes)) != -1)
// {
bufferedOutputStream.write(bytes, 0, count);
// }
} finally
{
if (null != bufferedInputStream)
{
try {
bufferedInputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (null != bufferedOutputStream)
{
try {
bufferedOutputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
输入输出流,JSP,文件上传
------解决方案--------------------
bufferedOutputStream 换成 FileOutputStream试试
------解决方案--------------------
你从哪传的?jsp页面?如果是页面,把页面发过来,感觉request里面就没收到数据
------解决方案--------------------
文件上传的时候注意是否设置类型为enctype=“multi/form-data”,服务器设置输入输出流编码了吗,还有选用的输入输出流是否合适。