批量下載的java代碼,java批量編譯

Java 批量大文件上傳下載如何實(shí)現(xiàn)?

解決這種大文件上傳不太可能用web上傳的方式,只有自己開發(fā)插件或是當(dāng)門客戶端上傳,或者用現(xiàn)有的ftp等。

成都創(chuàng)新互聯(lián)公司是少有的網(wǎng)站設(shè)計制作、成都網(wǎng)站制作、營銷型企業(yè)網(wǎng)站、成都小程序開發(fā)、手機(jī)APP,開發(fā)、制作、設(shè)計、買友情鏈接、推廣優(yōu)化一站式服務(wù)網(wǎng)絡(luò)公司,從2013年開始,堅持透明化,價格低,無套路經(jīng)營理念。讓網(wǎng)頁驚喜每一位訪客多年來深受用戶好評

1)開發(fā)一個web插件。用于上傳文件。

2)開發(fā)一個FTP工具,不用web上傳。

3)用現(xiàn)有的FTP工具。

下面是幾款不錯的插件,你可以試試:

1)Jquery的uploadify插件。具體使用。你可以看幫助文檔。

java爬蟲htmluinit框架批量下載文件?

我用Jsoup寫爬蟲,一般遇到html返回沒有的內(nèi)容。但是瀏覽器顯示有的內(nèi)容。都是分析頁面的http請求日志。分析頁面JS代碼來解決。

1、有些頁面元素被隱藏起來了-換selector解決

2、有些數(shù)據(jù)保存在js/json對象中-截取對應(yīng)的串,分析解決

3、通過api接口調(diào)用-偽造請求獲得數(shù)據(jù)

還有一個終極方法

4、使用phantomjs或者casperjs這種headless瀏覽器

JAVA 如何一次下載多個文件

創(chuàng)建多線程下載

如果說方便下載,是打包再下載

~~~~~~~~~~~~~~~~~~~~~~

JAVA 批量下載.zip

/**

* 報表查詢模塊 ----文件下載流

* @return

* @throws IOException

*/

public InputStream getInputStream() throws IOException {

InputStream ins = new FileInputStream(zipReports());

return ins;

}

/**

* 根據(jù)傳過來的報表編號壓縮文件為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);

//獲取應(yīng)用在服務(wù)器上的根目錄

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){

// 創(chuàng)建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 創(chuàng)建新的進(jìn)入點(diǎn)

// 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();

}

}

}

java 實(shí)現(xiàn)文件批量上傳下載實(shí)現(xiàn)方法 以及優(yōu)勢缺點(diǎn)

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;

文章標(biāo)題:批量下載的java代碼,java批量編譯
轉(zhuǎn)載來源:http://muchs.cn/article44/hssdhe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開發(fā)、靜態(tài)網(wǎng)站標(biāo)簽優(yōu)化、用戶體驗、網(wǎng)站營銷域名注冊

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司