嗯,我代码怎么没显示全部,再复制下,楼上的代码中有
- public class Test6 {
- public static void main(String[] args) {
- FileType ft = new FileType();
- System.out.println(ft.type("Java"));//在此输入文件的地址
- }
- }
- class FileType {
- private File file;
- private String name;
- public String type(String Path) {
- file = new File(Path);
- if (file.exists()) {
- System.out.println(file);
- name = file.getAbsolutePath();
- System.out.println(name);
- return name.substring(name.lastIndexOf(".") + 1, name.length());
- } else {
- return "你输入的文件无法读取扩展名";
- }
- }
- }
复制代码 |