This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Download remote jar file using java

 
shan raj
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there and welcome to Javaranch! Can you post a larger code example of what you have so far?
 
shan raj
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Martijn.

Yeah will take care of exception handling.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic