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);
        }
    }
}

 

相关文章:

  • 2022-01-09
  • 2021-11-28
  • 2021-11-16
  • 2021-07-16
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-25
  • 2021-09-02
  • 2021-12-04
  • 2022-02-26
  • 2021-12-09
  • 2022-02-04
  • 2022-01-14
相关资源
相似解决方案