download.java

来自「别人的代码」· Java 代码 · 共 28 行

JAVA
28
字号
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 + -
显示快捷键?