0

If If have a link like

http://localhost:8081/nexus/service/local/artifact/maven/redirect?r=artifactorycentral&g=com.sun.xml.ws&a=jaxws-rt&v=2.1.7&e=jar

to download a jar-File from my repository, how can I download and save this file in java?

I guess I have to open some kind of http connection, but I also guess that there should be a relatively direct and easy method to download such files.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • 3
    I guess theses answers should help you : http://stackoverflow.com/questions/921262/how-to-download-and-save-a-file-from-internet-using-java, http://stackoverflow.com/questions/8324862/how-to-create-file-object-from-url-object – Akah Feb 23 '16 at 10:57

1 Answers1

0

I usually create a URL object (java.net.URL), call its openStream method, read from the stream and store to disk. I don’t know if there is a way to avoid reading through the file in your own code. Hope it helps. Get back if you need more details.

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161