无痕客

落花无情,流水无痕……

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

自定义WORKSPACE的路径:

 configuration\config.ini  osgi.instance.area.default=@user.home/workspace

Eclipse 程序界面美化技术

http://www.ibm.com/developerworks/cn/opensource/os-cn-ecl-rcprich/

 

JAVA按指定编码读写文件

 

 ArrayList<String> nameArr=new ArrayList();
  StringBuilder builder=new StringBuilder();
  try {
 String txtPath="C:\\地名2.txt";
    String txtNewPath="C:\\地名3.txt";
   BufferedReader reader = new BufferedReader(new InputStreamReader(
     new FileInputStream(txtPath), "GBK"));
   String line = null;
   boolean first = true;
   while ((line = reader.readLine()) != null) {
    String[] names=line.split(" ");
    for (String name : names) {
     if(name.length()>2)
     {
      
      name=name.replace("市辖区", "").replace("自治县", "");
      name=name.replace("自治区", "");
      name=name.replace("县", "");
      name=name.replace("省", "");
      if(name.indexOf("市")>0)
      {
      String[] newNames=name.split("市");
      if(newNames==null)
       continue;
      if(newNames.length==1)
       name=newNames[0];
       else
        name=newNames[1]; 
      }
     }
     if(nameArr.indexOf(name)==-1)
     {
     nameArr.add(name);
     builder.append(name+"\r\n");
     }
    }
   }
   reader.close();
   BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(
     new FileOutputStream(txtNewPath), "GBK"));
   writer.write(builder.toString());
   writer.close();
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }

JAVA RCP开发 获取应用程序WORKSPACE下文件

 /**
  * 获取数据库路径
  * @return
  */
 public static String getDB() {
  Location instanceLocation = Platform.getInstanceLocation();
  URL path = instanceLocation.getURL();

  String strPath = path.getPath() + "GS.db";
  return strPath;
 }

 

获取RCP应用程序的启动运行路径

 

  File bundleFile=null;
  try {
   bundleFile = FileLocator.getBundleFile(Activator.getDefault().getBundle());
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  if(bundleFile==null)
   return null;
  File geosearchFolder = bundleFile.getAbsoluteFile();
  String geoSearchDisk= geosearchFolder.getParent();

 

根据VIEW ID获取相应的VIEW对象

   String viewID="com.geocompass.geosearch.views.filejudger";
   IViewPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(viewID);
   FileJudgerView judgeView=(FileJudgerView)part;
   judgeView.reloadData();

 

 

JAVA打开文件夹方式:

 

java.awt.Desktop.getDesktop().open(new File("D:\\Java"));  

 

删除文件夹以及文件夹内容

public void deleteFile(File targetFile)
{
  if(targetFile.isDirectory())
  {
   File[] list = targetFile.listFiles();
   for (int i = 0; i < list.length; i++) {
    deleteFile(list[i]);
   }
   //
   targetFile.deleteOnExit();
  }
  else
   targetFile.deleteOnExit();
}
posted on 2011-10-31 11:48  无痕客  阅读(3150)  评论(0编辑  收藏  举报