从给定的文件名修剪文件路径。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从给定的文件名修剪文件路径。相关的知识,希望对你有一定的参考价值。

  1. /**
  2.  * Trim the file path from the given file name. Anything before the last occurred "/" and "" will be
  3.  * trimmed, including the slash.
  4.  *
  5.  * @param fileName
  6.  * The file name to trim the file path from.
  7.  * @return The file name with the file path trimmed.
  8.  */
  9. public static String trimFilePath(String fileName) {
  10. return fileName.substring(fileName.lastIndexOf("/") + 1).substring(fileName.lastIndexOf("\") + 1);
  11. }

以上是关于从给定的文件名修剪文件路径。的主要内容,如果未能解决你的问题,请参考以下文章