fileInputstream方法异常

时间:2014-06-13 17:02:28

标签: java grails groovy fileinputstream

我正在尝试让我的代码从本地计算机读取excel文件,它给了我一个方法例外。

file f1 = new File("C://documents//test//testfile.xls")
path = f1.getAbsolutePath("C://documents//test//testfile.xls")
FileInputStream fis = new FileInputStream(path);


Caught: groovy.lang.MissingMethodException: No signature of method: static.com.genologics.client.bartender.midscript.file() is applicable for argument types: (java.io.File) values: [C:\documents\test\testfile.xls]
Possible solutions: find(), find(groovy.lang.Closure), use([Ljava.lang.Object;), is(java.lang.Object), with(groovy.lang.Closure), wait()
groovy.lang.MissingMethodException: No signature of method: static com.genologics.client.bartender.midscript.file() is applicable for argument types: (java.io.File) values: [C:\documents\test\testfile.xls]
Possible solutions: find(), find(groovy.lang.Closure), use([Ljava.lang.Object;), is(java.lang.Object), with(groovy.lang.Closure), wait()
    at com.genologics.client.bartender.midscript.main(CSVandManifestGenerator.groovy:43)

1 个答案:

答案 0 :(得分:1)

在您发布的代码中,f1的声明file为小写f。这可能不是你感兴趣的课程,但我可能会弄错。资本化F你应该没问题。

此外,您可以取消path变量,因为FileInputStream接受File对象作为构造函数参数。