package com.bd.test;
import java.io.File;
import java.io.IOException;
import java.net.URL;
public class csDao {
public static void main(String[] args)
{
csDao getclasspath = new csDao();
System.out.println(getclasspath.getClassPath());
File file = new File("index.html");
try {
System.out.println("获得webroot下文件的路径"+file.getCanonicalPath());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
*在类中取得当前文件所在的相对路径与绝对路径
*
* @return String
*/
public String getClassPath()
{
String strClassName = getClass().getName();
String strPackageName = "";