update at 2020-12-10 10:29:02 by ehlxr
This commit is contained in:
parent
7e5f38ef66
commit
1e8f9ef9f0
@ -12,10 +12,13 @@ public class ContentReplace {
|
|||||||
private static int unDeal = 0;
|
private static int unDeal = 0;
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
File dir = new File("/Users/ehlxr/WorkSpaces/enncloud/Ceres");
|
// File dir = new File("/Users/ehlxr/WorkSpaces/enncloud/Ceres");
|
||||||
deal(dir);
|
// deal(dir);
|
||||||
System.out.println("总文件数:" + total);
|
// System.out.println("总文件数:" + total);
|
||||||
System.out.println("未处理文件数:" + unDeal);
|
// System.out.println("未处理文件数:" + unDeal);
|
||||||
|
|
||||||
|
File license = new File("LICENSE");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void deal(File file) throws IOException {
|
private static void deal(File file) throws IOException {
|
||||||
|
@ -24,25 +24,24 @@ public class MyUrlDemo {
|
|||||||
|
|
||||||
// 第一种:获取类加载的根路径 D:\git\daotie\daotie\target\classes
|
// 第一种:获取类加载的根路径 D:\git\daotie\daotie\target\classes
|
||||||
File f = new File(this.getClass().getResource("/").getPath());
|
File f = new File(this.getClass().getResource("/").getPath());
|
||||||
System.out.println(f);
|
System.out.println("第一种:获取类加载的根路径 == " + f);
|
||||||
|
|
||||||
// 获取当前类的所在工程路径; 如果不加“/” 获取当前类的加载目录 D:\git\daotie\daotie\target\classes\my
|
// 获取当前类的所在工程路径; 如果不加“/” 获取当前类的加载目录 D:\git\daotie\daotie\target\classes\my
|
||||||
File f2 = new File(this.getClass().getResource("").getPath());
|
File f2 = new File(this.getClass().getResource("").getPath());
|
||||||
System.out.println(f2);
|
System.out.println("获取当前类的所在工程路径 == " + f2);
|
||||||
|
|
||||||
// 第二种:获取项目路径 D:\git\daotie\daotie
|
// 第二种:获取项目路径 D:\git\daotie\daotie
|
||||||
File directory = new File("");// 参数为空
|
String courseFile = new File("LICENSE").getCanonicalPath();
|
||||||
String courseFile = directory.getCanonicalPath();
|
System.out.println("第二种:获取项目路径 == " + courseFile);
|
||||||
System.out.println(courseFile);
|
|
||||||
|
|
||||||
|
|
||||||
// 第三种: file:/D:/git/daotie/daotie/target/classes/
|
// 第三种: file:/D:/git/daotie/daotie/target/classes/
|
||||||
URL xmlpath = this.getClass().getClassLoader().getResource("");
|
URL xmlpath = this.getClass().getClassLoader().getResource("");
|
||||||
System.out.println(xmlpath);
|
System.out.println("第三种 == " + xmlpath);
|
||||||
|
|
||||||
|
|
||||||
// 第四种: D:\git\daotie\daotie
|
// 第四种: D:\git\daotie\daotie
|
||||||
System.out.println(System.getProperty("user.dir"));
|
System.out.println("第四种 == " + System.getProperty("user.dir"));
|
||||||
/*
|
/*
|
||||||
* 结果: C:\Documents and Settings\Administrator\workspace\projectName
|
* 结果: C:\Documents and Settings\Administrator\workspace\projectName
|
||||||
* 获取当前工程路径
|
* 获取当前工程路径
|
||||||
|
Loading…
Reference in New Issue
Block a user