My goal is to read only the bytes from a file on a remote server starting at a particular byte position in the file without unnecessary data transfer. My concern is that without specifying an end byte, the entire file from the start byte is put into a buffer before any reads occur.
When one specifies a byte range in this fashion:
urlConn.setRequestProperty("Range","bytes="+byteRangeStart+"-")
and then subsequently obtains an InputStream, will that InputStream contain all the bytes of the file from byteRangeStart to the end of the file meaning that all the data is transferred when the InputStream is obtained or are bytes only transferred when the InputStream is read from?
Asking the server to start at a specific position won’t affect how the URLConnection works in the client.
When you read the InputStream on the URLConnection, data will only be transferred as you read it. There will be some data in network buffers at either end and so on of course, but I assume we’re talking about a reasonably large file here.