0

As I understand it, file.getAbsolutePath() gets the full path for a file. I thought file.getAbsoluteFile() would just get the file name, and not the path, but that didn't work. Basically I want to display the files and directories in a JTree, but for obvious reasons, I don't want the path. Just the name. How can I get this done?

1 Answers1

1

Use 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.

Andy Turner
  • 137,514
  • 11
  • 162
  • 243