So I’ve written a simple text editor in java, and it retrieves the file via showOpenDialog() and converts the filename into a string, so it can be displayed as the title:
String title = fc.getSelectedFile().toString();
But lets say I have the path “home/user/file.txt”. How would I strip off the path and make it so the filename displays as “file.txt” only?
File getName() returns what you want i.e just the last name in the pathname’s name sequence.