I'm an OSX user and currently using Play Framework, there is a weird issue when I use java.util.zip
to zip some files in a folder. The files will be auto generated (Done) into /Users/vorsz/Desktop/MonthlyReport/August
. But when I try to zip them using below code:
val baseURL: String = "/Users/vorsz/Desktop/MonthlyReport/"
val directoryToZip = new File(baseURL+"August").mkdir()
val writer = new PrintWriter(baseURL+"August/test.html", "UTF-8")
writer.println("<Table><tr><td>45296</td><td>2014-07-23</td><td>2014-08-01</td><td>010194</td><td></td><td>120</td><td>C-00322</td><td>ANK 007</td><td></td><td></td></tr></Table>")
writer.close()
val writer1 = new PrintWriter(baseURL+"August/test2.html", "UTF-8")
writer1.println("<Table><tr><td>45296</td><td>2014-07-23</td><td>2014-08-01</td><td>010194</td><td></td><td>120</td><td>C-00322</td><td>ANK 007</td><td></td><td></td></tr></Table>")
writer1.close()
val f = new FileOutputStream(baseURL+"test.zip")
val zip = new ZipOutputStream(new BufferedOutputStream(f))
zip.putNextEntry(new ZipEntry(baseURL+"August/test.html"))
zip.putNextEntry(new ZipEntry(baseURL+"August/test2.html"))
zip.close()
It will produce a zip file in a right folder, however when I extract it, it produces some unwanted folders like Users
,vorsz
,Desktop
and MonthlyReport
. So I need to open them up until I can access test.html
and test2.html
. What I want when I extract the zip file is only an August Folder with its files or the files itself, both way if possible. Can anyone help me here ?
Note: I also had tried implementing ZipUtils class, but still got same result..