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?
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