网络上有关Arcgis Engine For Java二次开发的资料很少,特在此记录下,希望能帮到其他人,同时也是给自己做个备忘录。
package com.tjm.zyy.Commands;
import java.io.IOException;
import java.net.UnknownHostException;
import com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory;
import com.esri.arcgis.geodatabase.IWorkspace;
import com.esri.arcgis.geodatabase.IWorkspaceFactory;
import com.esri.arcgis.geodatabase.IWorkspaceName;
import com.esri.arcgis.geodatabase.IWorkspaceProxy;
import com.esri.arcgis.system.IName;
import com.tjm.zyy.UI.Panel_Status;
public class CreateFileGeodatabase
{
/**
*
* @param filename 文件地理数据库名称
* @param filepath 地理数据库保存路径
* @return 地理数据库工作空间
*/
public IWorkspace CreateFGB(String filename, String filepath)//创建文件地理数据库
{
IWorkspace workspace = null;
try
{
if(filepath==null || filename==null)
{
return null;
}
if(filepath.equals("") || filename.equals(""))
{
return null;
}
IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactory();
IWorkspaceName workspaceName = workspaceFactory.create(filepath, filename, null, 0);
IName name = (IName)workspaceName;
workspace = new IWorkspaceProxy(name.open());
Panel_Status.setStatus("文件地理数据库创建成功", false);
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return workspace;
}
}