标签:try output write err input file exception leo put
(1)解决方式
public static File getTempFile(HttpServletRequest request, String name){ try { Part part = request.getPart("file"); InputStream is = part.getInputStream(); FileOutputStream fos = new FileOutputStream(getRequest().getRealPath("/") + name); byte[]buff=new byte[1024]; int len=0; while((len=is.read(buff))>0){ fos.write(buff); } is.close(); fos.close(); File fileTemp = new File(getRequest().getRealPath("/") + name); return fileTemp; } catch(Exception e) { System.err.println("上传文件错误:"+e); } return null; }
标签:try output write err input file exception leo put
原文地址:http://www.cnblogs.com/he0xff/p/6073914.html