hi ,
I have a doubt .
I have a 5mb file on a server . I am downloading the file from my java application
My application is NOT a web aplication I am using https connection to the sever
My code is something like this
public static void downloadFileSSL(String fileName) {
String urlPath = "https://200.216.221.25/";
int portNumber = 443;
try {
String hostName = "172.16.1.165";
SSLSocket serSoc = new SSLSocket(hostName,portNumber);
serSoc.setNeedClientAuth(false);
System.out.println("Connection "+serSoc.isConnected());
String fileURL = "/abc/"+fileName;
OutputStream out = serSoc.getOutputStream();
String msg = "GET " + fileURL + " HTTP/1.0\r\n\r\n" ;
byte b[];
try {
b = msg.getBytes("ASCII7");
}
catch (UnsupportedEncodingException ignored) {
b = msg.getBytes();
}
out.write(b);
out.flush();
BufferedInputStream bin = new BufferedInputStream
(serSoc.getInputStream());
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
int ch = 0;
while ((ch = bin.read()) != -1) {
byteStream.write(ch);
}
byte[] dataBytes = byteStream.toByteArray();
bin.close();
byteStream.close();
// Saving into the file
String outFile = "C:\\" + fileName;
FileOutputStream fileOut = new FileOutputStream(outFile);
fileOut.write(dataBytes);
fileOut.flush();
fileOut.close();
System.out.println("File Saved Sucessfully.....:"+ fileName);
} catch (IOException e) {
System.err.println(e);
e.printStackTrace();
}
catch (MalformedURLException e) {
System.err.println(e);
e.printStackTrace();
}
}
*****************************************
This code is working fine but to download that file it take lot of time.
I came to know that we can do https compressed request of that file if that
sever supports that. My server supports that .
So how to make such type of compressed request . what type of parameters
I have to pass with the http header...
Or else if u have any other suggestion please give it