• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using the File.exists method

 
Francois Dereims
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there.

For my application needs, I create one or several files per user on a remote disk.
Each file's name begins by the user's name:



This generates temp files looking like this: patrick.frinn-054589327793525214.sft
Now, further in the application (and from any running instance of the application) I have to search if some files, beginning with a certain user's name, does exist . I'm not sure on how to check this with the File.exists method.
Any idea ?
 
Ninad Kulkarni
Ranch Hand
Posts: 802
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not a exact way but I think some other methods of File class and other classes required to create such a search operation.
 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
File.exists() only works if you know the exact name of the file you are checking for. If you want to search for something like Francois*.sft, you can create a FilenameFilter and use it with File.list() on the parent directory.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!