lastname.java
来自「操作系统课程设计」· Java 代码 · 共 21 行
JAVA
21 行
public class LastName //获取文件后缀名"sss.ss" 返回 "ss" ; "sss." 返回 "." * "sss" 返回 ""
{
public static String getLast(String fileName)
{
int pos = fileName.lastIndexOf(".");
if (pos == -1)
return "";
return fileName.substring(pos, fileName.length());
}
/** * 获取除去后缀名后的文件名 * @param fileName 文件名 * @return 文件名 */
public static String getName(String fileName)
{
int pos = fileName.lastIndexOf(".");
if (pos == -1)
return fileName;
else
return fileName.substring(0, pos);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?