上传zip文件,解压缩并读取文件 [英] Upload a zip file, unzip and read file

查看:1372
本文介绍了上传zip文件,解压缩并读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用NetBeans,我正在一个jsp页面上允许上传zip文件。该zip文件包含6个CSV文件,即要写入SQL数据库。

i am using NetBeans, and i am working on a jsp page that allows the upload of a zip file. The zip file contains 6 CSV files, that is to be written to the SQL database.

我的问题是,我该如何允许用户上传文件,解压缩它在jsp页面,并允许我读取文件?提前感谢!

My question is, how do i go about allowing the user to upload the file, unzip it in the jsp page, and allow me to read the file? Thanks in advance!

推荐答案


  1. 添加< input type =文件> 并使表单 enctype =miltipart / form-data

  2. 使用 commons-fileupload 取得 byte [] (在您的servlet中)

  3. 使用 java.util.zip。 提取文件。 请参阅此处

  4. 解析CVS(此处),或者如果您的数据库具有导入CSV的实用程序,请使用 Runtime.exec(..)

  1. Add an <input type="file"> and make your form have enctype="miltipart/form-data"
  2. Use commons-fileupload to obtain the byte[] of the file (in a servlet of yours)
  3. Use java.util.zip.* to extract the files. See here
  4. Either parse the CVS (here) or if your database has an utility to import CSV, pass the files using Runtime.exec(..)

这篇关于上传zip文件,解压缩并读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆