Jump to content

Java Downloading Files

Hi i'm trying to downlaod a Jar file in my Java program and I run the program and it downloads it just fine when I run the downloaded jar file it runs just fine but when I stop it and run it again it all of a sudden is corrupted and it loses its icon and size. Hears the code that i used: 

URL website = new URL("URL");
				ReadableByteChannel rbc = Channels.newChannel(website.openStream());
				FileOutputStream fos = new FileOutputStream("SAVE LOCATION");
				fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
				fos.close();
				rbc.close();

Before: is the one with the icon 

After: is the one with no icon

befor.PNG

after.PNG

Link to comment
Share on other sites

Link to post
Share on other sites

your code above looks ok. Thats the one you use to download the initial jar file?

 

so what is the downloaded jar file doing?

 

and why are the icons you show "pdf" while you are talking about jar files? Thats all a bit weird... 

Link to comment
Share on other sites

Link to post
Share on other sites

7 hours ago, wemu said:

your code above looks ok. Thats the one you use to download the initial jar file?

 

so what is the downloaded jar file doing?

 

and why are the icons you show "pdf" while you are talking about jar files? Thats all a bit weird... 

The JAR file sends data from my servers to the main server about system info. The PDF icon is a custom ICON that i added just for fun also when I download it manually form the link manually it works just fine.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×