public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("已接收到请求");
//获取前台传过来的流信息
InputStream fileSource = req.getInputStream();
//临时文件存储位置
String tempFileName = "D:/temp/tempFile";
//创建临时文件
File tempFile = new File(tempFileName);
//输出流指向临时文件
FileOutputStream outputStream = new FileOutputStream(tempFile);
byte b[] = new byte[1024];
int n;
//从输入流读取内容写入到输出流
while(( n = fileSource.read(b)) != -1){
outputStream.write(b, 0, n);
}
//关闭输入、输出流
outputStream.close();
fileSource.close();
}
胜利女神在微笑
胜利女神在微笑
相关分类