且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Java读取路径中带有空格的文件

更新时间:2022-06-06 09:01:32

带空格的文件名可以正常工作

File name with space works just fine

这是我的代码

File f = new File("/Windows/F/Programming/Projects/NetBeans/TestApplications/database prop.properties");
        System.out.println(f.exists());
        try
        {
            FileInputStream stream = new FileInputStream(f);
        }
        catch (FileNotFoundException ex)
        {
            System.out.println(ex.getMessage());
        }

f.exists()始终返回true毫无问题