From 1e8f9ef9f031bb2f85f21e8cfb7936eade3a1bdf Mon Sep 17 00:00:00 2001 From: ehlxr Date: Thu, 10 Dec 2020 10:29:02 +0800 Subject: [PATCH] update at 2020-12-10 10:29:02 by ehlxr --- src/main/java/io/github/ehlxr/ContentReplace.java | 11 +++++++---- src/main/java/io/github/ehlxr/utils/MyUrlDemo.java | 13 ++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/github/ehlxr/ContentReplace.java b/src/main/java/io/github/ehlxr/ContentReplace.java index 598894f..db7e245 100644 --- a/src/main/java/io/github/ehlxr/ContentReplace.java +++ b/src/main/java/io/github/ehlxr/ContentReplace.java @@ -12,10 +12,13 @@ public class ContentReplace { private static int unDeal = 0; public static void main(String[] args) throws IOException { - File dir = new File("/Users/ehlxr/WorkSpaces/enncloud/Ceres"); - deal(dir); - System.out.println("总文件数:" + total); - System.out.println("未处理文件数:" + unDeal); + // File dir = new File("/Users/ehlxr/WorkSpaces/enncloud/Ceres"); + // deal(dir); + // System.out.println("总文件数:" + total); + // System.out.println("未处理文件数:" + unDeal); + + File license = new File("LICENSE"); + } private static void deal(File file) throws IOException { diff --git a/src/main/java/io/github/ehlxr/utils/MyUrlDemo.java b/src/main/java/io/github/ehlxr/utils/MyUrlDemo.java index 9ae6a9f..ded79e6 100644 --- a/src/main/java/io/github/ehlxr/utils/MyUrlDemo.java +++ b/src/main/java/io/github/ehlxr/utils/MyUrlDemo.java @@ -24,25 +24,24 @@ public class MyUrlDemo { // 第一种:获取类加载的根路径 D:\git\daotie\daotie\target\classes File f = new File(this.getClass().getResource("/").getPath()); - System.out.println(f); + System.out.println("第一种:获取类加载的根路径 == " + f); // 获取当前类的所在工程路径; 如果不加“/” 获取当前类的加载目录 D:\git\daotie\daotie\target\classes\my File f2 = new File(this.getClass().getResource("").getPath()); - System.out.println(f2); + System.out.println("获取当前类的所在工程路径 == " + f2); // 第二种:获取项目路径 D:\git\daotie\daotie - File directory = new File("");// 参数为空 - String courseFile = directory.getCanonicalPath(); - System.out.println(courseFile); + String courseFile = new File("LICENSE").getCanonicalPath(); + System.out.println("第二种:获取项目路径 == " + courseFile); // 第三种: file:/D:/git/daotie/daotie/target/classes/ URL xmlpath = this.getClass().getClassLoader().getResource(""); - System.out.println(xmlpath); + System.out.println("第三种 == " + xmlpath); // 第四种: 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 * 获取当前工程路径