-1

Is there an easy way to create a complete File object from a ZipEntry?

I'd prefer not to create my own streams with a buffer size and read into those streams by hand, such as the recommended way on these sites, https://stackoverflow.com/a/23870468/1005607 http://www.java-tips.org/java-se-tips-100019/38-java-util-zip/600-how-to-extract-filefiles-from-a-zip-file.html

If there's a utility method e.g. Apache or something that would be great.

Community
  • 1
  • 1
gene b.
  • 10,512
  • 21
  • 115
  • 227
  • Yes, extract the entry from the zip file onto your harddrive, then you have a "file" you can access normally using the Java `File` object. There are no other ways for a `File` object to access anything, since that is what a `File` object does. --- FYI: Would be different if you asked about the Java 7+ `Path` object, since it can access zip file entries. --- Curious: What are you going to do with that `File` object? Most Java code using `File` is using streams, so if you don't want to use streams, then what are you trying to do with it? – Andreas Oct 03 '16 at 17:43
  • I was asking if any libraries hide the stream code to give you a utility method to quickly obtain a File object. – gene b. Oct 03 '16 at 17:55
  • Ok, then I'm voting to close because [questions asking to recommend or find a software library are off-topic for Stack Overflow](http://stackoverflow.com/help/on-topic). – Andreas Oct 03 '16 at 17:57
  • [`Files.copy(zipFile.getInputStream(zipEntry), targetPath)`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#copy-java.io.InputStream-java.nio.file.Path-java.nio.file.CopyOption...-). – Holger Nov 04 '16 at 17:32

1 Answers1

-1

There's a nice article about your options, which consist of:

gtonic
  • 2,295
  • 1
  • 24
  • 32