📄 myclass.java~8~
字号:
package mythead;import java.net.*;import java.io.*;public class myClass extends Thread { String sURL; long nStartPos; long nEndPos; int i; int theFileLength; RandomAccessFile dst ; public static long nowDownLength; myClass(String url,RandomAccessFile f,long start, long end,int i,int theFileLength) { this.sURL = url; this.dst =f; this.nStartPos = start; this.nEndPos = end; this.i=i; this.theFileLength=theFileLength; } public void run() { try { URL url = new URL(sURL); HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection(); httpConnection.setRequestProperty("RANGE", "bytes=" + nStartPos + "-"); InputStream input = httpConnection.getInputStream(); byte[] b = new byte[1024]; int nRead; this.currentThread().setName(""+this.i); while ( (nRead = input.read(b, 0, 1024)) > 0 && nStartPos < nEndPos) { dst.seek(nStartPos); dst.write(b, 0, nRead); this.nowDownLength=nRead; nStartPos = nStartPos + nRead; System.out.println(""+this.currentThread().getName()+this.nowDownLength); } } catch (Exception ex) { ex.printStackTrace(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -