public static void main(String[] args) throws IOException {
//检查当前程序的工作目录
System.out.println(System.getProperty("user.dir"));
// 如果不是/开头的想对路径, 那就是从当前程序的工作目录开始找文件的
// Path path = Paths.get("opt/test.txt");
// String md5 = MD5Util.MD5(path.toFile());
// System.out.println(md5);
// 如果是/开头的话, 那就是从当前盘符开始找文件
Path path = Paths.get("/opt/test.txt");
String md5 = MD5Util.MD5(path.toFile());
System.out.println(md5);
}
【Paths.get 相对路径的使用】
最新推荐文章于 2025-03-19 16:43:17 发布