【后缀】保留最后点 输出后缀
public static void main(String[] args) { String input = "com.2022.2326.img.jpeg"; String output = lastDot(input); System.out.println(output); // 输出: .jpeg } public static String lastDot(String str) { int last = str.lastIndexOf('.'); if (last != -1) { return str.substring(last); } return str; }