Results 1 to 2 of 2
  1. #1
    leonard is offline Member
    Join Date
    Jul 2007
    Posts
    43
    Rep Power
    0

    Default how to download using java

    I'm trying to download a file using a java program.
    I want to send the range of bytes which I want to retrieve from the particular url.
    In the code I want to download the bytes from 100 to 150 and the file's size is of 500 bytes
    is the code correct?
    Java Code:
    URL url=new URL("exampleurl";
    URLConnection conn=url.openConnection();
    conn.setRequestProperty("Accept-Ranges","bytes");
    conn.setRequestProperty("Content-Range","bytes 100-150/500");
    dis = new DataInputStream(con1.getInputStream());
    message=dis .readLine();
    while(!message.equals(" ") )
    {
    System.out.println(message);
    message=dis .readLine();
    }
    thanks

  2. #2
    tommy is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

    Default

    try with this code

    Java Code:
    ArrayList<Byte> aba = new ArrayList<Byte>();
    int n;
    int counter = 0;
    
    try{
      URL url = new URL(".....");
      InputStrean is = url.openStream();
      while ((n = is.read()) != -1){
        ++counter;
        aba.add(byte)n);
      }
    }
    catch (Excption e){
      ...
    }
    // use ArrayList aba for subsequent task

Similar Threads

  1. Download JDK 1.5
    By Nick15 in forum New To Java
    Replies: 4
    Last Post: 01-01-2009, 03:10 AM
  2. What jdk do I download?
    By padutch2 in forum New To Java
    Replies: 3
    Last Post: 11-29-2007, 04:28 AM
  3. Help with download java api
    By fernando in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 02:36 AM
  4. Download Tracking
    By ganeshsalian in forum Advanced Java
    Replies: 7
    Last Post: 07-30-2007, 04:57 PM
  5. I could download JDK 1.5
    By Albert in forum New To Java
    Replies: 2
    Last Post: 07-13-2007, 03:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •