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);
    }
}

 

posted @ 2017-09-06 17:09  岁月淡忘了谁  阅读(128395)  评论(2编辑  收藏  举报