gpt4 book ai didi

java - 如何从文件中删除绝对路径?

转载 作者:行者123 更新时间:2023-12-02 10:34:52 26 4
gpt4 key购买 nike

据我了解,file.getAbsolutePath()获取文件的完整路径。我以为file.getAbsoluteFile()只会获取文件名,而不是路径,但这不起作用。基本上我想显示JTree中的文件和目录。 ,但出于显而易见的原因,我不想要这条路径。只是名字。我怎样才能完成这个工作?

最佳答案

使用file.getName() :

Returns the name of the file or directory denoted by this abstract pathname. This is just the last name in the pathname's name sequence.

关于java - 如何从文件中删除绝对路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53361102/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com