JAVA IO - 文件绝对路径

import java.io.File;


public class GetFilePath {
    public static void main(String args[]){
    	File file = new File("C:\\work\\hello\\helloworld.txt");
    	System.out.println("The file path is " + file.getAbsolutePath());
    	
    	String path = file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf(File.separator));
    	System.out.println("The abs path is " + path);
    }
}
相关文章
相关标签/搜索