Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用netbeans检查java中特定目录中的文件是否存在_Java_Netbeans_File Io - Fatal编程技术网

使用netbeans检查java中特定目录中的文件是否存在

使用netbeans检查java中特定目录中的文件是否存在,java,netbeans,file-io,Java,Netbeans,File Io,我有一个变量'chckwav'保存一个字符串值,字符串值基本上显示文件的路径 checkwav=path+"/wav/new1.wav";// where path variable is the path of file // 使用这个变量值,我必须检查指定路径中是否存在文件new1.wav。我分别使用了以下语法: - Files.notExists(checkwav) 及 但是两者都会抛出错误。根据您所说的(顺便说一句,没有实际说明错误是什么),当所述方法采用Pat

我有一个变量'chckwav'保存一个字符串值,字符串值基本上显示文件的路径

checkwav=path+"/wav/new1.wav";// where path variable is the path of file //         
使用这个变量值,我必须检查指定路径中是否存在文件
new1.wav
。我分别使用了以下语法:

-   Files.notExists(checkwav)

但是两者都会抛出错误。

根据您所说的(顺便说一句,没有实际说明错误是什么),当所述方法采用Path实例时,似乎您正试图将字符串实例传递给Files.exist方法

请尝试以下代码:

boolean exists = Files.exists(Paths.get(checkwav));

-托马斯

错误是什么?你能发布你的代码吗?在java.io.File上阅读javadoc netbeans是一个ide。如果您使用eclipse或Notepad,则应该是相同的。该网站不是阅读文档或搜索答案的替代品
boolean exists = Files.exists(Paths.get(checkwav));