This content has been marked as final. Show 8 replies
Zip files don't contain lines and they can't be printed with println(). You are corrupting the data with this I/O strategy.
Use count = read(byte buffer) and write(buffer, 0, count) when writing the file in the server.
ya.....it's working .. Thank for help
Can you pls advise how you made it to work?
I want to get a 3gp file (can it be treated as binary file?? ) from the remote server to a local machine. As per my understanding, it can be done in the steps as below:
1. open a URL connection to remote server
2. read the file in a byte array
3. write it to another file
(assuming that the mp4/3gp file can be treated like a zip file)
Can you please advise how can we read it in a byte array and write it to another file?
All "files" are binary data on a drive, CD, DVD, etc.
Reading anything as binary will give you thr RAW file, but no structure (file format), the format lies ontop of the file.
File formats like Zip, MP3, are just a way of looking at a file which can cause the underlying data to change, but will still be a stream of bits (binary data).
When reading it, you can get the whole file easily, but to recreate the data from the file, then, you'll need to understand the format and how that format changes data into bytes and bits.
For the original download Zip file issue, a person could use a ZipInputStream which is part of the java API.
Thanks for this information.
Do you have any suggestions as which one to be used for media files?
The ZipInputStream suggestion isn't relevant if you are just trying to download a ZIP. ZipInputStream is for opening a ZIP file and seeing what's inside it.
All file downloads are the same, whether they're ZIP files, media, text, JARs, Web pages, ...:
int count; byte buffer = new byte; // or more ... while ((count = in.read(buffer)) > 0) out.write(buffer, 0, count);
Agree with what you are saying. But based on your experience/expertise, would you please advise as why is not able to read the 3gp file at all? why for the zip files it reads 52 bytes only? It works well with the text files. All the files are stored in the same location and the files are all OK.
Can it be related to the download permissions? Is it possible that it may be configured on the webserver (somewhere) so as not to give access to 3gp/zip files ??(and may be thats why I can't open it using the browser as well ??)