Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring: how to parse uploaded zip file?
    primarykey
    data
    text
    <p>I uploaded my <strong>zip</strong> archive to the server and want to open <code>.txt</code> and <code>.jpg</code> files in it. I successfully get my archive in my Controller and get the name of each file via <code>ZipEntry</code>. Now I want to open it but for this I should get a full path to my file. </p> <p>I haven't found how I can do that. Could you suggest some approach how to do that ? </p> <p><strong>Update</strong></p> <p>I try to use example have been suggested below but I am not be able open the file</p> <pre><code>ZipFile zFile = new ZipFile("trainingDefaultApp.zip"); </code></pre> <p>I have got the <code>FileNotFoundException</code></p> <p>So I return to my start point. I have upload form in Java Spring application. In controller I had got a zip archive as <code>byte[]</code></p> <pre><code>@RequestMapping(method = RequestMethod.POST) public String create(UploadItem uploadItem, BindingResult bindingResult){ try { byte[] zip = uploadItem.getFileData().getBytes(); saveFile(zip); </code></pre> <p>Then I had got each <code>ZipEntry</code></p> <pre><code> InputStream is = new ByteArrayInputStream(zip); ZipInputStream zis = new ZipInputStream(is); ZipEntry entry = null; while ((entry = zis.getNextEntry()) != null) { String entryName = entry.getName(); if (entryName.equals("readme.txt")) { ZipFile zip = new ZipFile(entry.getName()); // here I had got an exception </code></pre> <p>According to docs I did all right but as for me it is strange to pass the file name only and suspect that you successfully will open the file</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload