Java获取文件后缀名
import java.io.File; public class Test { /** *author: itmyhome */ public static void main(String[] args) { File file = new File("HelloWorld.java"); String fileName = file.getName(); String suffix = fileName.substring(fileName.lastIndexOf(".") + 1); System.out.println(suffix); } }