Home  >  Article  >  Java  >  Java implementation of obtaining file type and extension

Java implementation of obtaining file type and extension

高洛峰
高洛峰Original
2017-02-27 16:09:021452browse

Java获取文件的类型和扩展名

实现代码:

File file=new File("E:\\aa.jpg"); 
String fileName=file.getName();    
String fileTyle=fileName.substring(fileName.lastIndexOf("."),fileName.length()); 
System.out.println(fileTyle);

程序运行效果图:

Java implementation of obtaining file type and extension

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

更多Java implementation of obtaining file type and extension相关文章请关注PHP中文网!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn