- 浏览: 505367 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (285)
- 数据库 (49)
- dwr (1)
- js (35)
- security (6)
- freemaker (4)
- 网站建设 (15)
- css (5)
- javaEE (56)
- 生活点滴 (12)
- 安装与配置 (16)
- ssh2 (13)
- 开源软件 (6)
- web 应用服务器 (6)
- 开发模式和设计模式 (2)
- linux (5)
- 项目管理 (7)
- 计算机杂症 (0)
- appScan (1)
- idea (3)
- android (1)
- java @override 报错处理 (1)
- lucene (5)
- java (2)
- groovy (1)
- Extjs (7)
- asp (2)
- php (2)
- Memcached (1)
- 名言 (1)
- 面试 (1)
- Jmeter (0)
- 微信支付 (1)
- app开发 (1)
- branch分支合并到trunk主干 (1)
- 自动化测试 (1)
- springClond (1)
- ELK (2)
最新评论
-
skykufo:
坑爹啊,我也因为写多了一个div,在ie8浪费了一天
jQuery加载(load、get、post)页面显示空白原因 -
yeyinzhu3211:
帅哥,我想问下,是怎么去除呀?能详细说明下吗?
IntelliJ IDEA 10.5.1 无法断点或停止不动 -
sshitaime:
怎么下载不了啊,能给我一个安装包吗
oracle 10g透明网关组件下载地址(新) -
fuanyu:
xiaohuafyle 写道被你的头像吓尿了 哥们有这么可怕呀 ...
netstat -aon -
wanlt_software:
谢谢。。。。。
oracle 10g透明网关组件下载地址(新)
本文来自:http://virgos.iteye.com/blog/254590
SiteFileFetch.java负责整个文件的抓取,控制内部线程(FileSplitterFetch类)。
FileSplitterFetch.java负责部分文件的抓取。
FileAccess.java负责文件的存储。
SiteInfoBean.java要抓取的文件的信息,如文件保存的目录,名字,抓取文件的URL等。
Utility.java工具类,放一些简单的方法。
TestMethod.java测试类
- /*
- **SiteFileFetch.java
- */
- package NetFox;
- import java.io.*;
- import java.net.*;
- public class SiteFileFetch extends Thread {
- SiteInfoBean siteInfoBean = null; //文件信息Bean
- long[] nStartPos; //开始位置
- long[] nEndPos; //结束位置
- FileSplitterFetch[] fileSplitterFetch; //子线程对象
- long nFileLength; //文件长度
- boolean bFirst = true; //是否第一次取文件
- boolean bStop = false; //停止标志
- File tmpFile; //文件下载的临时信息
- DataOutputStream output; //输出到文件的输出流
- public SiteFileFetch(SiteInfoBean bean) throws IOException
- {
- siteInfoBean = bean;
- //tmpFile = File.createTempFile ("zhong","1111",new File(bean.getSFilePath()));
- tmpFile = new File(bean.getSFilePath()+File.separator + bean.getSFileName()+".info");
- if(tmpFile.exists ())
- {
- bFirst = false;
- read_nPos();
- }
- else
- {
- nStartPos = new long[bean.getNSplitter()];
- nEndPos = new long[bean.getNSplitter()];
- }
- }
- public void run()
- {
- //获得文件长度
- //分割文件
- //实例FileSplitterFetch
- //启动FileSplitterFetch线程
- //等待子线程返回
- try{
- if(bFirst)
- {
- nFileLength = getFileSize();
- if(nFileLength == -1)
- {
- System.err.println("File Length is not known!");
- }
- else if(nFileLength == -2)
- {
- System.err.println("File is not access!");
- }
- else
- {
- for(int i=0;i<nStartPos.length;i++)
- {
- nStartPos[i] = (long)(i*(nFileLength/nStartPos.length));
- }
- for(int i=0;i<nEndPos.length-1;i++)
- {
- nEndPos[i] = nStartPos[i+1];
- }
- nEndPos[nEndPos.length-1] = nFileLength;
- }
- }
- //启动子线程
- fileSplitterFetch = new FileSplitterFetch[nStartPos.length];
- for(int i=0;i<nStartPos.length;i++)
- {
- fileSplitterFetch[i] = new FileSplitterFetch(siteInfoBean.getSSiteURL(),
- siteInfoBean.getSFilePath() + File.separator + siteInfoBean.getSFileName(),
- nStartPos[i],nEndPos[i],i);
- Utility.log("Thread " + i + " , nStartPos = " + nStartPos[i] + ", nEndPos = " + nEndPos[i]);
- fileSplitterFetch[i].start();
- }
- // fileSplitterFetch[nPos.length-1] = new FileSplitterFetch(siteInfoBean.getSSiteURL(),
- siteInfoBean.getSFilePath() + File.separator + siteInfoBean.getSFileName(),nPos[nPos.length-1],nFileLength,nPos.length-1);
- // Utility.log("Thread " + (nPos.length-1) + " , nStartPos = " + nPos[nPos.length-1] + ",
- nEndPos = " + nFileLength);
- // fileSplitterFetch[nPos.length-1].start();
- //等待子线程结束
- //int count = 0;
- //是否结束while循环
- boolean breakWhile = false;
- while(!bStop)
- {
- write_nPos();
- Utility.sleep(500);
- breakWhile = true;
- for(int i=0;i<nStartPos.length;i++)
- {
- if(!fileSplitterFetch[i].bDownOver)
- {
- breakWhile = false;
- break;
- }
- }
- if(breakWhile)
- break;
- //count++;
- //if(count>4)
- // siteStop();
- }
- System.err.println("文件下载结束!");
- }
- catch(Exception e){e.printStackTrace ();}
- }
- //获得文件长度
- public long getFileSize()
- {
- int nFileLength = -1;
- try{
- URL url = new URL(siteInfoBean.getSSiteURL());
- HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection ();
- httpConnection.setRequestProperty("User-Agent","NetFox");
- int responseCode=httpConnection.getResponseCode();
- if(responseCode>=400)
- {
- processErrorCode(responseCode);
- return -2; //-2 represent access is error
- }
- String sHeader;
- for(int i=1;;i++)
- {
- //DataInputStream in = new DataInputStream(httpConnection.getInputStream ());
- //Utility.log(in.readLine());
- sHeader=httpConnection.getHeaderFieldKey(i);
- if(sHeader!=null)
- {
- if(sHeader.equals("Content-Length"))
- {
- nFileLength = Integer.parseInt(httpConnection.getHeaderField(sHeader));
- break;
- }
- }
- else
- break;
- }
- }
- catch(IOException e){e.printStackTrace ();}
- catch(Exception e){e.printStackTrace ();}
- Utility.log(nFileLength);
- return nFileLength;
- }
- //保存下载信息(文件指针位置)
- private void write_nPos()
- {
- try{
- output = new DataOutputStream(new FileOutputStream(tmpFile));
- output.writeInt(nStartPos.length);
- for(int i=0;i<nStartPos.length;i++)
- {
- // output.writeLong(nPos[i]);
- output.writeLong(fileSplitterFetch[i].nStartPos);
- output.writeLong(fileSplitterFetch[i].nEndPos);
- }
- output.close();
- }
- catch(IOException e){e.printStackTrace ();}
- catch(Exception e){e.printStackTrace ();}
- }
- //读取保存的下载信息(文件指针位置)
- private void read_nPos()
- {
- try{
- DataInputStream input = new DataInputStream(new FileInputStream(tmpFile));
- int nCount = input.readInt();
- nStartPos = new long[nCount];
- nEndPos = new long[nCount];
- for(int i=0;i<nStartPos.length;i++)
- {
- nStartPos[i] = input.readLong();
- nEndPos[i] = input.readLong();
- }
- input.close();
- }
- catch(IOException e){e.printStackTrace ();}
- catch(Exception e){e.printStackTrace ();}
- }
- private void processErrorCode(int nErrorCode)
- {
- System.err.println("Error Code : " + nErrorCode);
- }
- //停止文件下载
- public void siteStop()
- {
- bStop = true;
- for(int i=0;i<nStartPos.length;i++)
- fileSplitterFetch[i].splitterStop();
- }
- }
/* **SiteFileFetch.java */ package NetFox; import java.io.*; import java.net.*; public class SiteFileFetch extends Thread { SiteInfoBean siteInfoBean = null; //文件信息Bean long[] nStartPos; //开始位置 long[] nEndPos; //结束位置 FileSplitterFetch[] fileSplitterFetch; //子线程对象 long nFileLength; //文件长度 boolean bFirst = true; //是否第一次取文件 boolean bStop = false; //停止标志 File tmpFile; //文件下载的临时信息 DataOutputStream output; //输出到文件的输出流 public SiteFileFetch(SiteInfoBean bean) throws IOException { siteInfoBean = bean; //tmpFile = File.createTempFile ("zhong","1111",new File(bean.getSFilePath())); tmpFile = new File(bean.getSFilePath()+File.separator + bean.getSFileName()+".info"); if(tmpFile.exists ()) { bFirst = false; read_nPos(); } else { nStartPos = new long[bean.getNSplitter()]; nEndPos = new long[bean.getNSplitter()]; } } public void run() { //获得文件长度 //分割文件 //实例FileSplitterFetch //启动FileSplitterFetch线程 //等待子线程返回 try{ if(bFirst) { nFileLength = getFileSize(); if(nFileLength == -1) { System.err.println("File Length is not known!"); } else if(nFileLength == -2) { System.err.println("File is not access!"); } else { for(int i=0;i<nStartPos.length;i++) { nStartPos[i] = (long)(i*(nFileLength/nStartPos.length)); } for(int i=0;i<nEndPos.length-1;i++) { nEndPos[i] = nStartPos[i+1]; } nEndPos[nEndPos.length-1] = nFileLength; } } //启动子线程 fileSplitterFetch = new FileSplitterFetch[nStartPos.length]; for(int i=0;i<nStartPos.length;i++) { fileSplitterFetch[i] = new FileSplitterFetch(siteInfoBean.getSSiteURL(), siteInfoBean.getSFilePath() + File.separator + siteInfoBean.getSFileName(), nStartPos[i],nEndPos[i],i); Utility.log("Thread " + i + " , nStartPos = " + nStartPos[i] + ", nEndPos = " + nEndPos[i]); fileSplitterFetch[i].start(); } // fileSplitterFetch[nPos.length-1] = new FileSplitterFetch(siteInfoBean.getSSiteURL(), siteInfoBean.getSFilePath() + File.separator + siteInfoBean.getSFileName(),nPos[nPos.length-1],nFileLength,nPos.length-1); // Utility.log("Thread " + (nPos.length-1) + " , nStartPos = " + nPos[nPos.length-1] + ", nEndPos = " + nFileLength); // fileSplitterFetch[nPos.length-1].start(); //等待子线程结束 //int count = 0; //是否结束while循环 boolean breakWhile = false; while(!bStop) { write_nPos(); Utility.sleep(500); breakWhile = true; for(int i=0;i<nStartPos.length;i++) { if(!fileSplitterFetch[i].bDownOver) { breakWhile = false; break; } } if(breakWhile) break; //count++; //if(count>4) // siteStop(); } System.err.println("文件下载结束!"); } catch(Exception e){e.printStackTrace ();} } //获得文件长度 public long getFileSize() { int nFileLength = -1; try{ URL url = new URL(siteInfoBean.getSSiteURL()); HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection (); httpConnection.setRequestProperty("User-Agent","NetFox"); int responseCode=httpConnection.getResponseCode(); if(responseCode>=400) { processErrorCode(responseCode); return -2; //-2 represent access is error } String sHeader; for(int i=1;;i++) { //DataInputStream in = new DataInputStream(httpConnection.getInputStream ()); //Utility.log(in.readLine()); sHeader=httpConnection.getHeaderFieldKey(i); if(sHeader!=null) { if(sHeader.equals("Content-Length")) { nFileLength = Integer.parseInt(httpConnection.getHeaderField(sHeader)); break; } } else break; } } catch(IOException e){e.printStackTrace ();} catch(Exception e){e.printStackTrace ();} Utility.log(nFileLength); return nFileLength; } //保存下载信息(文件指针位置) private void write_nPos() { try{ output = new DataOutputStream(new FileOutputStream(tmpFile)); output.writeInt(nStartPos.length); for(int i=0;i<nStartPos.length;i++) { // output.writeLong(nPos[i]); output.writeLong(fileSplitterFetch[i].nStartPos); output.writeLong(fileSplitterFetch[i].nEndPos); } output.close(); } catch(IOException e){e.printStackTrace ();} catch(Exception e){e.printStackTrace ();} } //读取保存的下载信息(文件指针位置) private void read_nPos() { try{ DataInputStream input = new DataInputStream(new FileInputStream(tmpFile)); int nCount = input.readInt(); nStartPos = new long[nCount]; nEndPos = new long[nCount]; for(int i=0;i<nStartPos.length;i++) { nStartPos[i] = input.readLong(); nEndPos[i] = input.readLong(); } input.close(); } catch(IOException e){e.printStackTrace ();} catch(Exception e){e.printStackTrace ();} } private void processErrorCode(int nErrorCode) { System.err.println("Error Code : " + nErrorCode); } //停止文件下载 public void siteStop() { bStop = true; for(int i=0;i<nStartPos.length;i++) fileSplitterFetch[i].splitterStop(); } }
- /*
- **FileSplitterFetch.java
- */
- package NetFox;
- import java.io.*;
- import java.net.*;
- public class FileSplitterFetch extends Thread {
- String sURL; //File URL
- long nStartPos; //File Snippet Start Position
- long nEndPos; //File Snippet End Position
- int nThreadID; //Thread's ID
- boolean bDownOver = false; //Downing is over
- boolean bStop = false; //Stop identical
- FileAccessI fileAccessI = null; //File Access interface
- public FileSplitterFetch(String sURL,String sName,long nStart,long nEnd,int id) throws IOException
- {
- this.sURL = sURL;
- this.nStartPos = nStart;
- this.nEndPos = nEnd;
- nThreadID = id;
- fileAccessI = new FileAccessI(sName,nStartPos);
- }
- public void run()
- {
- while(nStartPos < nEndPos && !bStop)
- {
- try{
- URL url = new URL(sURL);
- HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection ();
- httpConnection.setRequestProperty("User-Agent","NetFox");
- String sProperty = "bytes="+nStartPos+"-";
- httpConnection.setRequestProperty("RANGE",sProperty);
- Utility.log(sProperty);
- InputStream input = httpConnection.getInputStream();
- //logResponseHead(httpConnection);
- byte[] b = new byte[1024];
- int nRead;
- while((nRead=input.read(b,0,1024)) > 0 && nStartPos < nEndPos && !bStop)
- {
- nStartPos += fileAccessI.write(b,0,nRead);
- //if(nThreadID == 1)
- // Utility.log("nStartPos = " + nStartPos + ", nEndPos = " + nEndPos);
- }
- Utility.log("Thread " + nThreadID + " is over!");
- bDownOver = true;
- //nPos = fileAccessI.write (b,0,nRead);
- }
- catch(Exception e){e.printStackTrace ();}
- }
- }
- //打印回应的头信息
- public void logResponseHead(HttpURLConnection con)
- {
- for(int i=1;;i++)
- {
- String header=con.getHeaderFieldKey(i);
- if(header!=null)
- //responseHeaders.put(header,httpConnection.getHeaderField(header));
- Utility.log(header+" : "+con.getHeaderField(header));
- else
- break;
- }
- }
- public void splitterStop()
- {
- bStop = true;
- }
- }
/* **FileSplitterFetch.java */ package NetFox; import java.io.*; import java.net.*; public class FileSplitterFetch extends Thread { String sURL; //File URL long nStartPos; //File Snippet Start Position long nEndPos; //File Snippet End Position int nThreadID; //Thread's ID boolean bDownOver = false; //Downing is over boolean bStop = false; //Stop identical FileAccessI fileAccessI = null; //File Access interface public FileSplitterFetch(String sURL,String sName,long nStart,long nEnd,int id) throws IOException { this.sURL = sURL; this.nStartPos = nStart; this.nEndPos = nEnd; nThreadID = id; fileAccessI = new FileAccessI(sName,nStartPos); } public void run() { while(nStartPos < nEndPos && !bStop) { try{ URL url = new URL(sURL); HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection (); httpConnection.setRequestProperty("User-Agent","NetFox"); String sProperty = "bytes="+nStartPos+"-"; httpConnection.setRequestProperty("RANGE",sProperty); Utility.log(sProperty); InputStream input = httpConnection.getInputStream(); //logResponseHead(httpConnection); byte[] b = new byte[1024]; int nRead; while((nRead=input.read(b,0,1024)) > 0 && nStartPos < nEndPos && !bStop) { nStartPos += fileAccessI.write(b,0,nRead); //if(nThreadID == 1) // Utility.log("nStartPos = " + nStartPos + ", nEndPos = " + nEndPos); } Utility.log("Thread " + nThreadID + " is over!"); bDownOver = true; //nPos = fileAccessI.write (b,0,nRead); } catch(Exception e){e.printStackTrace ();} } } //打印回应的头信息 public void logResponseHead(HttpURLConnection con) { for(int i=1;;i++) { String header=con.getHeaderFieldKey(i); if(header!=null) //responseHeaders.put(header,httpConnection.getHeaderField(header)); Utility.log(header+" : "+con.getHeaderField(header)); else break; } } public void splitterStop() { bStop = true; } }
- /*
- **FileAccess.java
- */
- package NetFox;
- import java.io.*;
- public class FileAccessI implements Serializable{
- RandomAccessFile oSavedFile;
- long nPos;
- public FileAccessI() throws IOException
- {
- this("",0);
- }
- public FileAccessI(String sName,long nPos) throws IOException
- {
- oSavedFile = new RandomAccessFile(sName,"rw");
- this.nPos = nPos;
- oSavedFile.seek(nPos);
- }
- public synchronized int write(byte[] b,int nStart,int nLen)
- {
- int n = -1;
- try{
- oSavedFile.write(b,nStart,nLen);
- n = nLen;
- }
- catch(IOException e)
- {
- e.printStackTrace ();
- }
- return n;
- }
- }
/* **FileAccess.java */ package NetFox; import java.io.*; public class FileAccessI implements Serializable{ RandomAccessFile oSavedFile; long nPos; public FileAccessI() throws IOException { this("",0); } public FileAccessI(String sName,long nPos) throws IOException { oSavedFile = new RandomAccessFile(sName,"rw"); this.nPos = nPos; oSavedFile.seek(nPos); } public synchronized int write(byte[] b,int nStart,int nLen) { int n = -1; try{ oSavedFile.write(b,nStart,nLen); n = nLen; } catch(IOException e) { e.printStackTrace (); } return n; } }
- /*
- **SiteInfoBean.java
- */
- package NetFox;
- public class SiteInfoBean {
- private String sSiteURL; //Site's URL
- private String sFilePath; //Saved File's Path
- private String sFileName; //Saved File's Name
- private int nSplitter; //Count of Splited Downloading File
- public SiteInfoBean()
- {
- //default value of nSplitter is 5
- this("","","",5);
- }
- public SiteInfoBean(String sURL,String sPath,String sName,int nSpiltter)
- {
- sSiteURL= sURL;
- sFilePath = sPath;
- sFileName = sName;
- this.nSplitter = nSpiltter;
- }
- public String getSSiteURL()
- {
- return sSiteURL;
- }
- public void setSSiteURL(String value)
- {
- sSiteURL = value;
- }
- public String getSFilePath()
- {
- return sFilePath;
- }
- public void setSFilePath(String value)
- {
- sFilePath = value;
- }
- public String getSFileName()
- {
- return sFileName;
- }
- public void setSFileName(String value)
- {
- sFileName = value;
- }
- public int getNSplitter()
- {
- return nSplitter;
- }
- public void setNSplitter(int nCount)
- {
- nSplitter = nCount;
- }
- }
/* **SiteInfoBean.java */ package NetFox; public class SiteInfoBean { private String sSiteURL; //Site's URL private String sFilePath; //Saved File's Path private String sFileName; //Saved File's Name private int nSplitter; //Count of Splited Downloading File public SiteInfoBean() { //default value of nSplitter is 5 this("","","",5); } public SiteInfoBean(String sURL,String sPath,String sName,int nSpiltter) { sSiteURL= sURL; sFilePath = sPath; sFileName = sName; this.nSplitter = nSpiltter; } public String getSSiteURL() { return sSiteURL; } public void setSSiteURL(String value) { sSiteURL = value; } public String getSFilePath() { return sFilePath; } public void setSFilePath(String value) { sFilePath = value; } public String getSFileName() { return sFileName; } public void setSFileName(String value) { sFileName = value; } public int getNSplitter() { return nSplitter; } public void setNSplitter(int nCount) { nSplitter = nCount; } }
- /*
- **Utility.java
- */
- package NetFox;
- public class Utility {
- public Utility()
- {
- }
- public static void sleep(int nSecond)
- {
- try{
- Thread.sleep(nSecond);
- }
- catch(Exception e)
- {
- e.printStackTrace ();
- }
- }
- public static void log(String sMsg)
- {
- System.err.println(sMsg);
- }
- public static void log(int sMsg)
- {
- System.err.println(sMsg);
- }
- }
/* **Utility.java */ package NetFox; public class Utility { public Utility() { } public static void sleep(int nSecond) { try{ Thread.sleep(nSecond); } catch(Exception e) { e.printStackTrace (); } } public static void log(String sMsg) { System.err.println(sMsg); } public static void log(int sMsg) { System.err.println(sMsg); } }
- /*
- **TestMethod.java
- */
- package NetFox;
- public class TestMethod {
- public TestMethod()
- { ///xx/weblogic60b2_win.exe
- try{
- SiteInfoBean bean = new SiteInfoBean("http://localhost/xx/weblogic60b2_win.exe","L:\\temp","weblogic60b2_win.exe",5);
- //SiteInfoBean bean = new SiteInfoBean("http://localhost:8080/down.zip","L:\\temp","weblogic60b2_win.exe",5);
- SiteFileFetch fileFetch = new SiteFileFetch(bean);
- fileFetch.start();
- }
- catch(Exception e){e.printStackTrace ();}
- }
- public static void main(String[] args)
- {
- new TestMethod();
- }
- }
发表评论
-
java 模拟微信浏览器http请求
2020-12-16 08:49 934public static void main(St ... -
java 小数点处理的问题
2015-08-22 16:23 786float num= (float)1/100 ... -
java操作excel 替换指定字符串
2014-12-26 10:27 5313根据excel模板里设置指定的num0,num1,num2 ... -
itext对水印图片的旋转、放大、缩小等操作的示例
2014-07-24 17:17 5820package test1; import java. ... -
java 获取ip
2014-04-25 16:38 865public static String getIpAddr ... -
读取poi
2014-03-12 17:57 1336/** * Writer: fuanyu * Dat ... -
对Map排序
2014-02-20 15:38 795本来来自:http://blog.sina.com.cn/s ... -
java 上下篇文章实现的思路
2014-02-14 15:03 796当前文章的ID =request("id" ... -
Java:String和Date、Timestamp之间的转换
2013-12-03 14:39 10501.1 String -> Date String ... -
ArrayList和数组间的相互转换
2012-07-31 16:00 1119package test.test1; import ... -
No result defined for action and result
2012-07-02 11:50 1012当你在用struts2开发时,如果,从页面跳入action时, ... -
IntelliJ IDEA 10.0 使用javac 编译程序出现“非法字符: \65279 ”解决方法
2012-04-26 11:42 2184一、问题描述: 将在eclipse 创建的项目代码导入 I ... -
map取key及key的值
2012-03-19 15:53 1651public class Test2 { p ... -
用jdbc操作CLOB型数据的两种方式
2012-02-08 10:29 1305最近学Oracle,正好单位OA中Word文件是将文件用BAS ... -
java @override 报错处理
2012-02-02 14:14 1350有时候在自己电脑上编译通过的java代码,在别人那里确编译 ... -
Java判断字符串中是否包含汉字
2011-12-15 11:54 2295有两个方法 import java.util.regex.M ... -
JMagick+ImageMagic处理图片(高质量)
2011-11-27 13:37 2703项目需要简单处理一些用户上传的图片,如缩略图、剪切、旋转、水印 ... -
定时发送邮件的思路
2011-11-19 12:11 1311定时发送邮件:大概是用户选择在某个时间发送邮件; 步骤: ... -
java 解析json
2011-11-10 17:00 1139如下面代码 String str="[{'bus ... -
javamail 收邮件遇到的问题及解决方法
2011-11-04 16:29 23031.java.io.UnsupportedEncodingEx ...
相关推荐
Java 断点续传技术是网络传输中常用的一种机制,特别是在大文件下载或上传时,如果因为网络中断或其他原因导致传输失败,可以借助断点续传功能从上次中断的地方继续,而无需重新开始。在Java中实现断点续传,通常...
Java实现断点续传是一项在文件传输中非常实用的技术,特别是在大文件传输或者网络不稳定的情况下。断点续传允许用户在文件传输中断后从上次中断的位置继续,而不是重新开始整个传输过程,极大地提高了效率和用户体验...
Java断点续传技术在实际应用中广泛用于文件上传和下载工具,如迅雷、FTP客户端等,它有效地解决了大文件传输过程中的网络问题,提高了用户体验。了解并掌握这种技术对于开发高效的网络应用至关重要。
总之,Java断点续传技术是提高大文件下载效率的重要手段,通过HTTP的Range请求实现与服务器的交互,确保用户可以在任何时间点继续未完成的下载任务。在实际开发中,我们需要注意处理各种异常情况,以提供稳定可靠的...
Java 断点续传技术是网络传输中一种高效的数据...通过以上分析,我们可以看出Java断点续传涉及到了网络编程、文件操作、状态管理和错误处理等多个方面的知识,它在实际应用中能有效提高大文件传输的效率和用户体验。
Java 断点续传技术是Java编程中一种重要的文件传输策略,主要用于大文件的上传和下载,能够提高网络效率并优化用户体验。在处理大文件时,由于网络不稳定、用户操作中断或其他因素,可能会导致文件传输失败。断点续...
本源码项目是基于Java的FastDFS大文件上传与断点续传设计,包含36个文件,主要使用Java、JavaScript和CSS编程语言。该项目旨在实现h5与fastdfs之间的高性能断点续传、秒传、大文件上传以及使用redis文件锁。系统提供...
综上所述,Java断点续传技术涉及网络编程、文件操作和异常处理等多个方面,通过合理的实现可以显著提高大文件下载的效率和用户体验。理解并掌握这些知识点对于开发高效的文件下载应用至关重要。
Java 断点续传上传是一种在文件传输过程中,如果因为网络中断或其他原因导致传输不完整,可以从上次中断的位置继续上传的技术。这种技术尤其在大文件传输时非常有用,避免了因网络问题而需要重新上传整个文件的困扰...
本项目是一个基于Vue和Java的断点续传与大文件上传系统设计源码,共包含563个文件,其中包括258个Java文件、82个SVG文件等。系统采用了Vue-uploader和若依框架,为用户提供了一个便捷的文件上传解决方案。系统支持多...
java实现FTP多线程断点续传,上传下载! - java学习与交流 - j2ee学习网 - j2ee学习网 (2012年5月21日) 用 Java 实现断点续传 (HTTP) (2012年5月21日) Java写的支持断点续传的FTP--crybaby的博客 (2012年5月21日) ...
总之,Java断点续传技术结合进度条插件,为大文件上传提供了高效和用户友好的解决方案。通过合理利用如`HttpUploader5Utf8MySQL`这样的工具,开发者可以轻松实现这一功能,并结合MySQL数据库进行状态管理,提升系统...
Java 断点续传的原理主要涉及到网络编程、文件处理以及多线程技术。断点续传是指在上传或下载大文件时,如果因为网络中断或其他原因导致传输不完整,可以从上次中断的地方继续传输,而不需要从头开始,极大地提高了...
标题"XuChuanFTP_Java_FTP断点续传"可能是指一个Java实现的FTP客户端库或者一个示例项目,专注于支持FTP的断点续传功能。这个项目可能是为了帮助开发者更方便地处理大文件的上传任务,尤其是在网络不稳定的情况下。 ...
Java 断点续传是一种在下载大文件时...通过以上这些知识点,您可以构建一个功能完备的Java断点续传下载器。实际开发时,还需要考虑其他因素,如网络状况的动态适应、下载策略优化等,以提供更高效和稳定的下载体验。
本资料包“基于C#的WebAPI断点续传几种方式及WebClient断点续传下载.zip”主要探讨了两种在C#环境下实现断点续传的方法:一是通过WebAPI实现服务端的断点续传功能,二是使用WebClient类进行客户端的断点续传下载。...
### 用Java实现断点续传的技术解析 #### 一、技术原理概述 断点续传是一种在网络连接不稳定或在下载过程中出现意外中断时能够继续完成下载的技术。它通过记录下载过程中断时的位置,当重新启动下载任务时,可以从...
"多线程断点续传工具类"通常指的是一个Java类,该类设计用于实现文件传输时的多线程功能,并且能够从上次中断的地方继续下载或上传,这在大文件传输中非常有用,因为它可以提高速度并避免因网络问题导致的传输失败。...