Fortune Telling Collection - Comprehensive fortune-telling - In java, I want to get the path and file name of the last folder in a path. How come?

In java, I want to get the path and file name of the last folder in a path. How come?

There are several ways.

You can divide the string by' \' to get the last one.

You can also find the position of the last' \' and remove the following characters.

Others didn't expect to see some functions of String class for the time being.