将 BufferedInputStream 传递给接受 InputStream 的方法
Passing BufferedInputStream to a method that accepts InputStream
我正在调用一个接受 InputStream
的方法。这是 github 上的方法:https://github.com/drewnoakes/metadata-extractor/blob/2.8.0/Source/com/drew/imaging/ImageMetadataReader.java#L89
我正在使用 BufferedInputStream
调用该方法,该方法应该有效,因为它是 InputStream
的子项,但我不断收到此错误:
No signature of method: static com.drew.imaging.ImageMetadataReader.readMetadata() is applicable for argument types: (java.io.BufferedInputStream) values: [java.io.BufferedInputStream@74d4ec5f]
Possible solutions: readMetadata(java.io.File), readMetadata(java.io.BufferedInputStream, boolean). Stacktrace follows:
Message: No signature of method: static com.drew.imaging.ImageMetadataReader.readMetadata() is applicable for argument types: (java.io.BufferedInputStream) values: [java.io.BufferedInputStream@74d4ec5f]
Possible solutions: readMetadata(java.io.File), readMetadata(java.io.BufferedInputStream, boolean)
Line | Method
->> 137 | settings in com.foo.scanner.AdminController
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 53 | doFilter in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter
| 62 | doFilter in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
| 59 | doFilter in grails.plugin.springsecurity.web.SecurityRequestHolderFilter
这是我的代码:
println file62.name //prints name of the file
println file62.inputStream.getClass() //prints java.io.BufferedInputStream
InputStream is = (InputStream)file62.inputStream
Metadata metadata = com.drew.imaging.ImageMetadataReader.readMetadata(is) //readMetadata expects InputStream
我拥有的库版本:
✗ grails dependency-report | grep "drew"
+--- com.drewnoakes:metadata-extractor:2.9.1
+--- com.drewnoakes:metadata-extractor:2.9.1
+--- com.drewnoakes:metadata-extractor:2.9.1
异常表示该方法需要 File
或 BufferedInputStream
和 布尔值。没有期望 only a BufferedInputStream
.
的重载
如果您确定形式参数和实际参数匹配,那么这种异常(由形式参数不匹配引起)的最可能原因是周围有一个旧罐子。 运行 mvn clean
、gradle clean
,检查您的 Web 容器的 lib 目录,并通常从您的系统中删除错误的 jars。
@PaulHicks 完全正确。早在 2012 年,您调用的 API 就被误导并因极端偏见而被删除,提交如下:
GitHub 表示 API 已在 2.7.0 版本中删除。
我正在调用一个接受 InputStream
的方法。这是 github 上的方法:https://github.com/drewnoakes/metadata-extractor/blob/2.8.0/Source/com/drew/imaging/ImageMetadataReader.java#L89
我正在使用 BufferedInputStream
调用该方法,该方法应该有效,因为它是 InputStream
的子项,但我不断收到此错误:
No signature of method: static com.drew.imaging.ImageMetadataReader.readMetadata() is applicable for argument types: (java.io.BufferedInputStream) values: [java.io.BufferedInputStream@74d4ec5f]
Possible solutions: readMetadata(java.io.File), readMetadata(java.io.BufferedInputStream, boolean). Stacktrace follows:
Message: No signature of method: static com.drew.imaging.ImageMetadataReader.readMetadata() is applicable for argument types: (java.io.BufferedInputStream) values: [java.io.BufferedInputStream@74d4ec5f]
Possible solutions: readMetadata(java.io.File), readMetadata(java.io.BufferedInputStream, boolean)
Line | Method
->> 137 | settings in com.foo.scanner.AdminController
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 53 | doFilter in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter
| 62 | doFilter in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
| 59 | doFilter in grails.plugin.springsecurity.web.SecurityRequestHolderFilter
这是我的代码:
println file62.name //prints name of the file
println file62.inputStream.getClass() //prints java.io.BufferedInputStream
InputStream is = (InputStream)file62.inputStream
Metadata metadata = com.drew.imaging.ImageMetadataReader.readMetadata(is) //readMetadata expects InputStream
我拥有的库版本:
✗ grails dependency-report | grep "drew"
+--- com.drewnoakes:metadata-extractor:2.9.1
+--- com.drewnoakes:metadata-extractor:2.9.1
+--- com.drewnoakes:metadata-extractor:2.9.1
异常表示该方法需要 File
或 BufferedInputStream
和 布尔值。没有期望 only a BufferedInputStream
.
如果您确定形式参数和实际参数匹配,那么这种异常(由形式参数不匹配引起)的最可能原因是周围有一个旧罐子。 运行 mvn clean
、gradle clean
,检查您的 Web 容器的 lib 目录,并通常从您的系统中删除错误的 jars。
@PaulHicks 完全正确。早在 2012 年,您调用的 API 就被误导并因极端偏见而被删除,提交如下:
GitHub 表示 API 已在 2.7.0 版本中删除。