下载代码 //file 为真实文件(从ftp或者数据库中获取) try { FileInputStream fins = new FileInputStream(file); System.out.println(file.getName().getBytes()); response.setHeader("Content-disposition", "attachment; filename=" + new String((file.getName()).getBytes(), "ISO-8859-1")); response.setContentType("application/msexcel; charset=GB2312"); ServletOutputStream sopt = response.getOutputStream(); byte buffer[] = new byte[8192]; while (fins.read(buffer) != -1) { sopt.write(buffer); } //关闭 清除 sopt.flush(); sopt.close(); fins.close(); file.delete();//删除缓存文件 } catch (Exception e) { // TODO: handle exception } 上传 //通过ftp工具类将文件上传到ftp服务器中 //param1为缓存文件地址 //param2为ftp的远程地址 boolean boo = ftpUtils.putFile(localpath + "//" + filename, File.separator + remotepath); //boo 为上传结果 //ftp工具类使用的是下图中的FileUtils(org.apache.commons.io.FileUtils)