0

Hi I need to download a file from a http server which askes for user id and password to login. can someone help me out in downloading the file and place that in a database table.

Thanks in advance

Neela.V

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by masijade
0

Hi masijade,
I used the following code. That works only for sites which doesn'task for login credentials. My requirement is with login credentials. Please help me out.

import java.io.*;
import java.net.*;
public class SampleFile
{
public static void main(String args[]) throws IOException
{

java.io.BufferedInputStream in = new java.io.BufferedInputStream(new

java.net.URL("http://bdonline.sqe.com/documents/testplans.pdf").openStream());
java.io.FileOutputStream fos = new java.io.FileOutputStream("testplans.pdf");
java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
byte data[] = new byte[1024];
while(in.read(data,0,1024)>=0)
{
bout.write(data);
}
bout.close();
in.close();
}
}


Thanks
Neela.V

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.