aomega
asked on
Quesion about HTTP Get Request
I am having some difficulty sending an http get request to the server through a socket connection, downloading binary data located in a relative folder on the server and then writing it to a local file.
sock = new Socket(server, port);
in = new DataInputStream(sock.getIn putStream( ));
out = new DataOutputStream(sock.getO utputStrea m());
String request = "GET /folder/folder/datafile HTTP 1.0\r\n\r\n";
//then i send the get request to the server
out.writeBytes(request);
The problem is that I when i go to read the response from the socket into a byte array and write the bytearray to the file; the data either is not written at all (filesize is 0) or in some cases the data is partially written. Is there something I am doing wrong with the get request? Any comments would be appreciated. Thanks
sock = new Socket(server, port);
in = new DataInputStream(sock.getIn
out = new DataOutputStream(sock.getO
String request = "GET /folder/folder/datafile HTTP 1.0\r\n\r\n";
//then i send the get request to the server
out.writeBytes(request);
The problem is that I when i go to read the response from the socket into a byte array and write the bytearray to the file; the data either is not written at all (filesize is 0) or in some cases the data is partially written. Is there something I am doing wrong with the get request? Any comments would be appreciated. Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.innovation.ch/java/HTTPClient/