我正在尝试将内容保存在文件中,但首先我想搜索任一文件是否存在。但是我写的代码,每次都返回true。
String fileName=FNameTextField.getText();
File file=new File(fileName);
if(file.exists()&& !file.isDirectory()) {
// It returns true if File or directory does exist
System.out.println("the file or directory you are searching does exist : " );
}else{
// It returns true if File or directory not exists
System.out.println("the file or directory you are searching does not exist : " );
}
谢谢。