Hi friends,
I have a servlet coding where i can download a folder from FTP.
The folder is zipped and stored in the FTP server.
While the client downloads the zip file the it should be unzipped and stored in the client machine.
Here is the code..
While trying to compile the servlet code it's fine but when the servlet is executed the following exception occurs
Exception : java.util.zip.Z ipException: The filename, directory name, or volume label syntax is incorrect.
Can anyone help me out..
Thanks in advance
I have a servlet coding where i can download a folder from FTP.
The folder is zipped and stored in the FTP server.
While the client downloads the zip file the it should be unzipped and stored in the client machine.
Here is the code..
Code:
import javax.servlet.http.*; import javax.servlet.*; import javax.servlet.ServletOutputStream; import java.io.*; import java.awt.*; import java.util.*; import java.util.zip.*; import java.net.*; public class TempDownload1 extends HttpServlet{ public static void unzip(ZipFile zip, Component parentComponent, File outputDir) throws IOException {} public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { byte[] buffer = new byte[16384]; //source ZipFile zip=new ZipFile("ftp://username:pswd@xxx.xx.xxx.xx/location/filename.zip"); Component parentComponent=null; //destination File outputDir = new File("C:/"); Enumeration entries = zip.entries(); for ( int i = 0; entries.hasMoreElements(); ) { ZipEntry entry = (ZipEntry) entries.nextElement(); File File = new File(outputDir, entry.getName()); File.getParentFile().mkdirs(); if (!entry.isDirectory()) { InputStream in = null; OutputStream out = null; try { in = zip.getInputStream(entry); out = new FileOutputStream(File); for (int n = 0; (n = in.read(buffer)) > -1; ) out.write(buffer, 0, n); } finally { try { out.close(); } catch (IOException e) {} } } } unzip(zip, parentComponent ,outputDir); } }
Exception : java.util.zip.Z ipException: The filename, directory name, or volume label syntax is incorrect.
Can anyone help me out..
Thanks in advance
Comment