Download zip files using java






















Add a comment. Active Oldest Votes. Improve this answer. Jon Skeet Jon Skeet 1. If you're getting a response then the problem can't be in the actual reading part Sign up or log in Sign up using Google.

Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast what if you could invest in your favorite developer? You normally don't want to use it for pure file downloads. BalusC - I have the same problem. My zip files get corrupted when I download using Java but the web browser works fine.

What is the line of code that specifies the user agent that I need to add? You'd better not fix the problem directly in question, as it would invalidate the concrete question. Instead just post an answer which concretely answers the problem in question. That's where Stack Overflow is all about. Show 3 more comments. Active Oldest Votes. Improve this answer. Somnath Musib 3, 2 2 gold badges 26 26 silver badges 42 42 bronze badges. Skip Head Skip Head 6, 1 1 gold badge 28 28 silver badges 34 34 bronze badges.

Wouldn't matter. If it returns 0, then there's simply nothing to write and thus also no need to write. Yes, it matters. I agree with zockman. Add a comment. Ray Ray 21 2 2 bronze badges. Did you try looking what the file that you downloaded actually contains? One thing that looks suspicious to me is the content type that you set. It could be that the server is reporting an "invalid content type" error. My file contains binary data. You have to use one of the standard content types, that the server understands.

When you download the file with your browser instead of a Java program, the browser will also send a 'Content-Type' header to the server, containing a standard content type. Jesper point taken. I will get back with this change you have suggested. Carey Brown. Saloon Keeper. If your talking about the zip file on the server, I would assume it's binary. If you are talking about the file that you downloaded with your code, then no, I would not make the assumption that the file is binary, even if the file name has a.

You could open it up with VI or some other editor and look to see if it isn't perhaps an html file. Carey - I know for sure that the zip files do contain binary files. Dave Tolls. The zip file is still corrupted. We hope you enjoyed this article. If you have any questions or comments, feel free to reach out to jacob initialcommit. Recommended product: Coding Essentials Guidebook for Developers. Subscribe to be notified when we release new content and features!

Follow Us.



0コメント

  • 1000 / 1000