java 参数“目录”不是目录参数的目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31466292/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Parameter 'directory' is not a directory for a parameter which is a directory
提问by mosawi
I'm getting a strange error where the parameter I supply to a method complains that it's not a directory but it IS in fact a directory with files in it...I don't understand what's wrong...
我收到一个奇怪的错误,我提供给方法的参数抱怨它不是一个目录,但它实际上是一个包含文件的目录......我不明白出了什么问题......
Toplevel:
顶层:
public static File mainSchemaFile = new File("src/test/resources/1040.xsd");
public static File contentDirectory = new File("src/test/resources/input");
public static File outputDirectory = new File("src/test/resources/output");
DecisionTableBuilder builder =constructor.newInstance(log, contentDirectory, outputDirectory);
// Here is where the error occurs
builder.compile(mainSchemaFile);
The class I'm using:
我正在使用的课程:
public class DecisionTableBuilder {
public void compiler(File schemaFile) {
...
// It's complaining about contentDirectory, it goes to FileUtils class for this
Collection<File> flowchartFiles = FileUtils.listFiles(contentDirectory, mapExtension, true);
...
}
}
Here is the apache FileUtils class:
这是 apache FileUtils 类:
public class FileUtils {
private static void validateListFilesParameters(File directory, IOFileFilter fileFilter) {
if (!directory.isDirectory()) {
throw new IllegalArgumentException("Parameter 'directory' is not a directory");
}
if (fileFilter == null) {
throw new NullPointerException("Parameter 'fileFilter' is null");
}
}
}
Output: Parameter 'directory' is not a directory
输出:参数“目录”不是目录
Which is the error output I am getting...
这是我得到的错误输出...
Anyone have any idea what is happening here I'm super confused...any help will be greatly appreciated.
任何人都知道这里发生了什么,我非常困惑......任何帮助将不胜感激。
EDIT:
编辑:
In my toplevel I added the following line:
在我的顶层中,我添加了以下行:
if(contentDirectory.isDirectory()) {
System.out.println("Content Directory: "+contentDirectory);
}
Output: src/test/resources/input
回答by Andrew Yaremchyk
You're pointing to the file and not a directory in mainSchemaFile
variable. Reduce the path to the folder containing 1040.xsd
- it should resolve the issue.
您指向的是文件而不是mainSchemaFile
变量中的目录。减少包含文件夹的路径1040.xsd
- 它应该可以解决问题。