views:

48

answers:

1

Hello,

How do I save a remote file (i.e. http://example.com/somefile.pdf) to blackberry's local disk from my custom app

Thanks

+2  A: 

Open a HttpConnection with Connector.open(URL). Then open an InputStream from that connection e.g:

HttpConnection conn = (HttpConnection) Connector.open("http://example.com/somefile.pdf");
InputStream in = conn.openInputStream();

Edit: To save the file to a disk open a FileConnection and open an OutputStream from there. e.g:

    FileConnection file = (FileConnection) Connector.open("file:///store/home/user/myfile.pdf");
file.create();
OutputStream out = file.openOutputStream();
Jonathan
So How do I write the inputstream to disk?
hishboy