当前位置:首页 » 编程语言 » java文件的批量下载

java文件的批量下载

发布时间: 2022-05-27 18:21:05

java ftp上批量下载。。。如何和本地文件对应比较。。

比较文件名、比较文件大小,或者比较文件字节序列。最绝的方法是比较文件的MD5值!

⑵ Java 批量大文件上传下载如何实现

解决这种大文件上传不太可能用web上传的方式,只有自己开发插件或是当门客户端上传,或者用现有的ftp等。
1)开发一个web插件。用于上传文件。
2)开发一个FTP工具,不用web上传。
3)用现有的FTP工具。
下面是几款不错的插件,你可以试试:
1)Jquery的uploadify插件。具体使用。你可以看帮助文档。

⑶ JAVA 如何一次下载多个文件

创建多线程下载
如果说方便下载,是打包再下载
~~~~~~~~~~~~~~~~~~~~~~

⑷ java 实现文件批量上传下载实现方法 以及优势缺点

File file = new File(path);
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String tempString = null;
StringBuffer buffer = new StringBuffer();
while ((tempString = reader.readLine()) != null) {
buffer.append(tempString);
}
reader.close();
return buffer.toString();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {

}
}
}
return null;

⑸ JAVA 批量下载.zip

/**
* 报表查询模块 ----文件下载流
* @return
* @throws IOException
*/
public InputStream getInputStream() throws IOException {
InputStream ins = new FileInputStream(zipReports());
return ins;
}

/**
* 根据传过来的报表编号压缩文件为zip
* @param response
* @param serverPath
* @param str
* @throws IOException
*/
public File zipReports() throws IOException{
List<StatisticalReport> srclist = new ArrayList<StatisticalReport>();
String[] pks = ids.split(",");
if(pks.length > 0){
for(String pk : pks){
String[] str = pk.split("\\|");
StatisticalReport obj = new StatisticalReport();
obj.setCendat(str[0]);
obj.setOrgidt(str[1]);
obj.setRep_code(str[2]);
obj.setCurcde(str[3]);
srclist.add(obj);
}
}
StatisticalReport obj = new StatisticalReport();
obj.setReportList(srclist);
//查询要下载的报表文件
List<StatisticalReport> list = statisticalReportService.findReportList(obj);
//获取应用在服务器上的根目录
String path = request.getSession().getServletContext().getRealPath(System.getProperty("file.separator"));
List<File> srcList = new ArrayList<File>();
if(list.size() > 0){
for(StatisticalReport statisticalReport : list){
File file = new File(statisticalReport.getFile_path());
if(file.exists()){
srcList.add(file);
}
}
}

Pim_sysUser user = (Pim_sysUser) session.getAttribute(SysConstant.SESSION_USER_DATA);
File zipfile = new File(path + System.getProperty("file.separator") + user.getLogid() + "REPORT.zip");
if(zipfile.exists()){
zipfile.delete();
zipfile.createNewFile();
}
//FileTools.File(, res.getString("help_path"), newFormatFileName);// 上传文件
ZipUtils.zipFiles(srcList, zipfile);
return zipfile;
}

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class ZipUtils {
/**
* 将多个Excel打包成zip文件
*
* @param srcfile
* @param zipfile
*/
public static void zipFiles(List<File> srcfile, File zipfile) {
byte[] buf = new byte[2048];
try {
// Create the ZIP file
// Compress the files
if(srcfile.size() > 0){
// 创建ZipOutputStream类对象
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipfile));
for (int i = 0; i < srcfile.size(); i++) {
File file = srcfile.get(i);
FileInputStream in = new FileInputStream(file);
// Add ZIP entry to output stream.
out.putNextEntry(new ZipEntry(file.getName()));// 写入此目录的Entry 创建新的进入点
// Transfer bytes from the file to the ZIP file
int len;
while ((len = in.read(buf)) > 0) {
out.setLevel(9);
out.write(buf, 0, len);
}
// Complete the entry
out.closeEntry();
in.close();
}
out.close();
}else{
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipfile));
out.putNextEntry(new ZipEntry(" "));
out.closeEntry();
out.close();
}
// Complete the ZIP file
} catch (IOException e) {
e.printStackTrace();
}
}
}

⑹ 请问如何在不用struts框架,只用JSP、serverlet、java的情况下实现文件的批量下载,谢谢

批量下载是什么意思啊?

可以提交给一个servlet,然后把文件流写入到response中,这和用不用struts框架没有关系。
出现乱码,是下载流里的字符集没有设置,具体的记不清了,属性方法里挨个试也出来了。

看你的意思好象是,一个页面上有多个checkbox选择,点下载按钮,把选中的都下载下来,
建议多做一个压缩的功能,把选择的做成一个压缩包。只下载一次,如果连续弹出多个下载框的话,对性能的影响有些大。

⑺ 通过java实现文件下载

在jsp/servlet中断点/多线程下载文件
<%@ page import="java.io.File" %><%@ page import="java.io.IOException" %><%@ page import="java.io.OutputStream" %><%@ page import="java.io.RandomAccessFile" %><%! public void downloadFile(HttpServletRequest request, HttpServletResponse response, File file) throws IOException { RandomAccessFile raf = new RandomAccessFile(file, "r"); java.io.FileInputStream fis = new java.io.FileInputStream(raf.getFD()); response.setHeader("Server", "www.trydone.com"); response.setHeader("Accept-Ranges", "bytes"); long pos = 0; long len; len = raf.length(); if (request.getHeader("Range") != null) { response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT); pos = Long.parseLong(request.getHeader("Range") .replaceAll("bytes=", "") .replaceAll("-", "") ); } response.setHeader("Content-Length", Long.toString(len - pos)); if (pos != 0) { response.setHeader("Content-Range", new StringBuffer() .append("bytes ") .append(pos) .append("-") .append(Long.toString(len - 1)) .append("/") .append(len) .toString() ); } response.setContentType("application/octet-stream"); response.setHeader("Content-Disposition", new StringBuffer() .append("attachment;filename=\"") .append(file.getName()) .append("\"").toString()); raf.seek(pos); byte[] b = new byte[2048]; int i; OutputStream outs = response.getOutputStream(); while ((i = raf.read(b)) != -1) { outs.write(b, 0, i); } raf.close(); fis.close(); }%><% String filePath = request.getParameter("file"); filePath = application.getRealPath(filePath); File file = new File(filePath); downloadFile(request, response, file);%>
是否可以解决您的问题?

⑻ java爬虫htmluinit框架批量下载文件

我用Jsoup写爬虫,一般遇到html返回没有的内容。但是浏览器显示有的内容。都是分析页面的http请求日志。分析页面JS代码来解决。
1、有些页面元素被隐藏起来了->换selector解决
2、有些数据保存在js/json对象中->截取对应的串,分析解决
3、通过api接口调用->伪造请求获得数据
还有一个终极方法
4、使用phantomjs或者casperjs这种headless浏览器

⑼ java ftp批量下载异常

我之前也遇到过这样的事,通过FTP获取文件的二进制流有限制,获取第二个流的时候需要断掉链接后再重新连接服务器读取流

⑽ java response.getOutputStream()实现多个文件下载,已经拿到两个字节数组的list,下载的时候如何同时下载

可以一个接口传多个文件,每个文件中间用特定符号拆分,也可以写一个接口前端多次调用,将请求头的文件格式改为blob,前端获取文件流后调用下载

热点内容
编程vlb 发布:2025-02-12 13:33:17 浏览:783
电脑出现无法解析服务器的dns对策 发布:2025-02-12 13:29:12 浏览:158
硬盘的存储空间是以簇为单位 发布:2025-02-12 13:26:06 浏览:356
我的帐号密码是什么 发布:2025-02-12 13:24:37 浏览:281
网页版传奇源码下载 发布:2025-02-12 13:23:48 浏览:828
模型预估算法 发布:2025-02-12 13:09:46 浏览:708
武汉存储 发布:2025-02-12 13:09:43 浏览:204
国内外密码箱锁哪里有卖 发布:2025-02-12 13:02:47 浏览:237
杰杰脚本 发布:2025-02-12 13:02:07 浏览:35
uc高级编程 发布:2025-02-12 13:01:57 浏览:788