How to specify filepath in java?

If you know the name of the file, of course it’s simply

new File("./myFileName")

If you don’t know the name, you can use the File object’s list() method to get a list of files in the current directory, and then pick the one you want.

Leave a Comment