download.java
来自「这是一个基于java的多线程下载工具!大家用用看怎样」· Java 代码 · 共 27 行
JAVA
27 行
import java.io.*;
import java.net.*;
public class DownLoad{
URL url;
String objFile;
long nStartPos;
RandomAccessFile rf;
public DownLoad(String objFile,long nStartPos) throws IOException{
this.nStartPos=nStartPos;
this.objFile=objFile;
rf=new RandomAccessFile(objFile,"rw");
rf.seek(nStartPos);
}//实现下载功能
public synchronized int write(byte[] b,int nStart,int len){
int n=-1;
try{
rf.write(b,nStart,len);
n=len;
}catch(IOException ioe){
ioe.printStackTrace();
}
return n;
}
public void close()throws IOException{
rf.close();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?