Posted on 2005-06-24 15:59 
morcble的blog 阅读(303) 
评论(0)  编辑  收藏  所属分类: 
Java 
			 
			
		 
		//删除文件  无论a是文件还是文件夹
public class file {
 public static void deleteDirectoryorFile(java.io.File a){//全路径
  if (a.isFile()){
   a.delete();
  }
  else{
   java.io.File[] files = a.listFiles();
   for(int i= 0 ;i<files.length;i++){
    deleteDirectoryorFile(files[i]);
   }
   a.delete();
  }
 }
}
 
 
 
 
**
 * 
 * web-inf的相对路径 调用方法 Getpath.path();
 */
public class Getpath {
 private String path;
 private static Getpath s;//静态单例模式
 public Getpath() {
  path = this.getClass().getResource("Getpath.class").getPath();
  path = path.substring(0, path.indexOf("WEB-INF"));
  path = path + "WEB-INF/";
 }
 public void setpath(String path) {
  this.path = path;
 }
 public String getpath() {
  return this.path;
 }
 public static String path() {
  if (s == null)
   s = new Getpath();
  return (s.getpath());
 }
 public static void main(String[] args) {
  System.out.println(Getpath.path());
 }
}
 
 
/**
*
* @author  Administrator
*/
public class TestCmd {
    public TestCmd(){}
    public static void main(String args[]){
        try {
          Process process = Runtime.getRuntime().exec("cmd.exe  /c  start  http://www.hao123.net/");  //登录网站
         // Process process = Runtime.getRuntime().exec("cmd.exe  /c  start  ping 10.5.2.19");  //调用Ping命令
        }catch (Exception  e)
        {
            e.printStackTrace();
            }  
        
      }
    }