当前位置:网站首页>File file = new file ("test.txt") file path

File file = new file ("test.txt") file path

2022-06-11 03:07:00 zfoo-framework

public class TestFile2 {
    public static void main(String[] args) throws Exception{
        File f = new File("test.txt");
        if(!f.exists()){
            System.out.println("file not exist");
            boolean newFile = f.createNewFile();
        }else {
            System.out.println("file exist");
        }
        System.out.println(f.getAbsolutePath());
    }
}

Conclusion :

1. Direct operation java, Is under the project path

2,. Package and run jar, And jar Under the same level directory of the package

原网站

版权声明
本文为[zfoo-framework]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110242398980.html