package com.yd.wmsc.util;

import java.io.File;

public class FileTest {
public static void main(String[] args) {
/*File file=new File("d:/");
for (File f : file.listFiles()) {
if (f.isFile()) {
System.out.println(f);
}
}*/
File directory = new File(".");//设定为当前文件夹
try{
System.out.println(directory.getCanonicalPath());//获取标准的路径
System.out.println(directory.getAbsolutePath());//获取绝对路径 System.out.println(directory.getPath());
System.out.println(directory.getParent());
System.out.println(directory.toPath());
System.out.println(System.getProperty("user.dir") );
System.out.println(FileTest.class.getClass().getResource("/").getPath());
}catch(Exception e){}
}
}

D:\workspace\wmsc
D:\workspace\wmsc\.
.
null
.
D:\workspace\wmsc
/D:/workspace/wmsc/target/classes/

05-11 18:10