• 大小: 61.93MB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-12-30
  • 语言: 其他
  • 标签: arcgisapi  

资源简介

readZipShp,js读取shp文件

资源截图

代码片段和文件信息

package com.controls;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.zip.ZipInputStream;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

import com.utils.MyFileRead;
import com.utils.SelectFile;
import com.utils.ToGeoJson;
import com.utils.ZipUtils;

public class readFile extends HttpServlet {
public void doGet(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
doPost(request response);

}
public void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
 //设置编码utf-8
 request.setCharacterEncoding(“utf-8“);
 response.setCharacterEncoding(“utf-8“); 
 DiskFileItemFactory dfif = new DiskFileItemFactory();
     ServletFileUpload upload = new ServletFileUpload(dfif);
     upload.setSizeMax(5 * 1024 * 1024);
     try {
List list = upload.parseRequest(request);
if (list.size() > 0) {
            FileItem item = (FileItem) list.get(0);
            String name = item.getName();
            name=name.substring(0 name.length()-4);
            InputStream in=item.getInputStream();
            ZipInputStream zis=new ZipInputStream(in);
        ZipUtils.unzipFromStream(zis “e:\\temp“);
        File files=new File(“e:\\temp\\“+name);
        File []file=files.listFiles(new SelectFile(“shp“));
        String jsonPath=ToGeoJson.toGeojson(file[0].getAbsolutePath());
        String result=MyFileRead.readToString(jsonPath); 
        response.getWriter().write(““);
        }
} catch (FileUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}


}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        607  2016-12-27 13:33  readZipShp\readZipShp\readZipShp\.classpath

     文件        303  2017-01-08 17:09  readZipShp\readZipShp\readZipShp\.mymetadata

     文件       1753  2016-12-24 17:50  readZipShp\readZipShp\readZipShp\.project

     文件        500  2016-12-24 16:59  readZipShp\readZipShp\readZipShp\.settings\.jsdtscope

     文件         57  2016-12-26 21:37  readZipShp\readZipShp\readZipShp\.settings\org.eclipse.core.resources.prefs

     文件        364  2016-12-24 16:59  readZipShp\readZipShp\readZipShp\.settings\org.eclipse.jdt.core.prefs

     文件        468  2016-12-24 16:59  readZipShp\readZipShp\readZipShp\.settings\org.eclipse.wst.common.component

     文件        252  2016-12-24 16:59  readZipShp\readZipShp\readZipShp\.settings\org.eclipse.wst.common.project.facet.core.xml

     文件         49  2016-12-24 16:59  readZipShp\readZipShp\readZipShp\.settings\org.eclipse.wst.jsdt.ui.superType.container

     文件          6  2016-12-24 16:59  readZipShp\readZipShp\readZipShp\.settings\org.eclipse.wst.jsdt.ui.superType.name

     文件    2196480  2016-12-27 12:59  readZipShp\readZipShp\readZipShp\src\cairo.dll

     文件    1204224  2016-12-27 12:59  readZipShp\readZipShp\readZipShp\src\cfitsio.dll

     文件       2266  2016-12-27 18:36  readZipShp\readZipShp\readZipShp\src\com\controls\readFile.java

     文件        960  2016-12-27 18:36  readZipShp\readZipShp\readZipShp\src\com\utils\IOUtil.java

     文件       1074  2016-12-27 09:10  readZipShp\readZipShp\readZipShp\src\com\utils\MyFileRead.java

     文件        516  2016-12-26 21:52  readZipShp\readZipShp\readZipShp\src\com\utils\SelectFile.java

     文件       1260  2016-12-26 22:32  readZipShp\readZipShp\readZipShp\src\com\utils\ToGeoJson.java

     文件       4679  2016-12-27 18:36  readZipShp\readZipShp\readZipShp\src\com\utils\ZipUtils.java

     文件     137728  2016-12-27 12:59  readZipShp\readZipShp\readZipShp\src\expat.dll

     文件      71680  2016-12-27 12:59  readZipShp\readZipShp\readZipShp\src\freexl.dll

     文件     123392  2016-12-27 12:59  readZipShp\readZipShp\readZipShp\src\fribidi.dll

     文件   12859904  2016-12-27 12:59  readZipShp\readZipShp\readZipShp\src\gdal111.dll

     文件      36864  2016-12-27 13:00  readZipShp\readZipShp\readZipShp\src\gdalconstjni.dll

     文件     293376  2016-12-27 13:00  readZipShp\readZipShp\readZipShp\src\gdaljni.dll

     文件    1368064  2016-12-27 12:59  readZipShp\readZipShp\readZipShp\src\geos.dll

     文件     278528  2016-12-27 12:59  readZipShp\readZipShp\readZipShp\src\geos_c.dll

     文件    2293760  2016-12-27 12:59  readZipShp\readZipShp\readZipShp\src\hdf5.dll

     文件     279040  2016-12-27 12:59  readZipShp\readZipShp\readZipShp\src\hdf5_cpp.dll

     文件     103424  2016-12-27 12:59  readZipShp\readZipShp\readZipShp\src\hdf5_hl.dll

     文件       9728  2016-12-27 12:59  readZipShp\readZipShp\readZipShp\src\hdf5_hl_cpp.dll

............此处省略12853个文件信息

评论

共有 条评论