| Author |
Download remote jar file using java
|
shan raj
Ranch Hand
Joined: Dec 16, 2008
Posts: 42
|
|
Hi, I want to write a java program to download remote jar file. Any one please help me to proceed further. Btw, I tried using the below API. but when I open a jar file its not opening. URL url = new URL("http:\\.....jar"); InputStream in=url.openStream (); Read as byte array and save into another file using output stream.
|
 |
Martijn Verburg
author
Bartender
Joined: Jun 24, 2003
Posts: 3268
|
|
|
Hi there and welcome to Javaranch! Can you post a larger code example of what you have so far?
|
Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
|
 |
shan raj
Ranch Hand
Joined: Dec 16, 2008
Posts: 42
|
|
Hi, I got the answer how to download. There was a problem in writing into the file using BufferedOutputStream. Initially I read the file and written without doing bufOut.flush(). After doing this it worked fine. Here is the code which i tried. if any one has good alternative or effective approach of downloading file please reply me.
|
 |
Martijn Verburg
author
Bartender
Joined: Jun 24, 2003
Posts: 3268
|
|
That seems OK although I'm going to assume that in your PRD quality code you'll have the Exception handling, remove the System.out.println etc
|
 |
shan raj
Ranch Hand
Joined: Dec 16, 2008
Posts: 42
|
|
Thanks Martijn. Yeah will take care of exception handling.
|
 |
 |
|
|
subject: Download remote jar file using java
|
|
|