package com.wzh.test.http;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class RangeDemo {
package com.wzh.test.http;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class RangeDemo {
public static void main(String[] args) throws IOException {
URL url=new URL("http://127.0.0.1:8080/day04_http/a.txt");
URLConnection conn=url.openConnection();
conn.setRequestProperty("Range", "bytes=5-");
InputStream in=conn.getInputStream();
int len=0;
byte buffer[]=new byte[1024];
FileOutputStream out=new FileOutputStream("c:\\a.txt",true);
while((len=in.read(buffer))>0){
out.write(buffer, 0, len);
}
}
}