So I am writing a code that locates certain information on Protein databases. I know that a recursive folder search is the best possible way to locate these files, but I am very new to this language and have been told to write in Java (I normally do C++)
SO this being said, what method would i use to:
First: Locate the folder on desktop
Second: Open each folder and that folders subfolders
Third: Locate files that end with the ".dat" type (because these are the only files that have stored the Protein information
Thanks for any and all help you can provide
Best Answer
File
object represents a directory)So, with that information...
You would specify a path location with something like...
You can check that the
File
is a directory with...You can list the contents of the directory by...
You can filter the list in a similar way...
Other useful methods would include (but not limited to)
File.exists
to test that the file actually existsFile.isFile
, basically instead of saying!File.isDirectory()
File.getName()
, returns the name of the file, excluding it's pathFile.getPath()
returns the path and name of the file. This can be relative, so be careful, seeFile.getAbsolutePath
andFile.getCanonicalPath
to resolve this.File.getParentFile
which gives you access to the parent folder