• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I make a list of folders only record the file name and not the directory it's in?

 
Walker Lockard
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Whenever I execute this snippit, I get the entire directory.

EXAMPLE:

I would simply like for the output name to be shown.
 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) use listOfFiles[0].getName()

2) use list() instead of listFiles(). list() returns a String[] with the file names instead of a File[]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!