Create zip outputstream from inputstream




















Java ArrayList. Popular Examples Check prime number. Print the Fibonacci series. Print Pyramids and Patterns. Multiply two matrices.

Find the standard deviation. Reference Materials String. Start Learning Java. Explore Java Examples. Java BufferedOutputStream Class. Java ObjectOutputStream Class. Java OutputStreamWriter Class. Subclasses of OutputStream In order to use the functionality of OutputStream , we can use its subclasses. Methods of OutputStream. Previous Tutorial:. I want to change it back to zip file and save it. FileTransfer have 3 methods, getInputStream is one of them.

It returns InputStream from FileTransfer object. In my case, fileTransfer object holds zip file and as well as InputStream object too. I have done, lot of searches in google. But i am not able to find one example, that illustrates InputStream to zip conversion. I tried this code, by thought of a typical file copy program.

I know it is false, just tried. It gives me java. ZipException: ZIP file must have at least one entry. See the examples java2s, input and output. If you have more questions feel free to ask them :. For clarity, in this input example you should do something like:. As Don Roby correctly said, if you just want to copy you need not know the file structure and you could use for example static IOUtils.

Further, if you do wish to extract the ZIP file contents, you should not plainly copy bytes. Every Entry is a compressed file or the data thereof with the original name:. Please note the javadoc of getNextEntry :.

If your input is a an InputStream from a zip file and your desired output is still a zip file with the same contents, you're just doing a file copy operation and shouldn't have to worry about zip at all. Learn more. Asked 11 years, 2 months ago. Active 3 years, 9 months ago.

Viewed 11k times. I would like to create a java. ZipOutputStream or a apache. Improve this question. Add a comment.

Active Oldest Votes. Yes this is absolutely possible! Improve this answer. Adrian Smith Adrian Smith Alright, that worked! But how do I create Directories that actually contain the files themselves then? Right now I get all files, fine, but the directories are unpacked as files with zero-byte length in the root node, so no hierarchy at all :- — trajectory. ZIP files just contain a flat list of files. The file names, however, may contain path information.



0コメント

  • 1000 / 1000