Can you tell me how to get the file name from the absolute path string in Java?
I created a file as follows:
String myDirectoryPath = "C:\\projects\\example\\myFile.txt";
File myDirectory = new File(myDirectoryPath);
Now when I use
System.out.println(myDirectory); I get the absolute path of a file.
How do I only get the
myFile.txt as a String?
I found the solution.
use getName() method: