解決這種大文件上傳不太可能用web上傳的方式,只有自己開發插件或是當門客戶端上傳,或者用現有的ftp等。
成都創新互聯公司是少有的網站設計制作、成都網站制作、營銷型企業網站、成都小程序開發、手機APP,開發、制作、設計、買友情鏈接、推廣優化一站式服務網絡公司,從2013年開始,堅持透明化,價格低,無套路經營理念。讓網頁驚喜每一位訪客多年來深受用戶好評
1)開發一個web插件。用于上傳文件。
2)開發一個FTP工具,不用web上傳。
3)用現有的FTP工具。
下面是幾款不錯的插件,你可以試試:
1)Jquery的uploadify插件。具體使用。你可以看幫助文檔。
我用Jsoup寫爬蟲,一般遇到html返回沒有的內容。但是瀏覽器顯示有的內容。都是分析頁面的http請求日志。分析頁面JS代碼來解決。
1、有些頁面元素被隱藏起來了-換selector解決
2、有些數據保存在js/json對象中-截取對應的串,分析解決
3、通過api接口調用-偽造請求獲得數據
還有一個終極方法
4、使用phantomjs或者casperjs這種headless瀏覽器
創建多線程下載
如果說方便下載,是打包再下載
~~~~~~~~~~~~~~~~~~~~~~
/**
* 報表查詢模塊 ----文件下載流
* @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{
ListStatisticalReport srclist = new ArrayListStatisticalReport();
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);
//查詢要下載的報表文件
ListStatisticalReport list = statisticalReportService.findReportList(obj);
//獲取應用在服務器上的根目錄
String path = request.getSession().getServletContext().getRealPath(System.getProperty("file.separator"));
ListFile srcList = new ArrayListFile();
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.copyFile(, 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(ListFile 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();
}
}
}
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代碼,java批量編譯
轉載來源:http://vcdvsql.cn/article44/hssdhe.html
成都網站建設公司_創新互聯,為您提供App開發、靜態網站、標簽優化、用戶體驗、網站營銷、域名注冊
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯