1

I have some code that does:

content = Java::byte[s].new
f = tar.read(content, 0, s)
content_stream = ByteArrayInputStream.new(content)

So far, so good

But when I try to use a method that only takes an InputStream, like so:

metadata = ImageMetadataReader.readMetadata(content_stream)

I get the following exception:

NameError: no method 'readMetadata' for arguments (java.io.ByteArrayInputStream) on Java::ComDrewImaging::ImageMetadataReader

I've tried using content_stream.to_java(java.io.InputStream) and that still generates the same error. Any ideas?

Kai
  • 38,985
  • 14
  • 88
  • 103
clee
  • 10,943
  • 6
  • 36
  • 28

2 Answers2

1

The single-argument readMetadata() takes a file; there is a two-argument that takes a *Buffered*InputStream and a boolean. You could wrap your ByteArrayInputStream in a BufferedInputStream and decide whether you want to 'waitForBytes', whatever that means...

arcy
  • 12,845
  • 12
  • 58
  • 103
  • The BufferedInputStream was the answer! I thought I was going crazy, but I was just looking at the wrong version of ImageMetadataReader.java - from master, not 2.6.4, which is the version I'm actually using. Thanks! – clee May 16 '13 at 08:21
0

It's because readMetadata has 2 signatures, one with one argument: a java.io.File and a second which you try to use that takes 2 arguments a ByteArrayInputStream and a boolean. Try to replace your code with ImageMetadataReader.readMetadata(content_stream, false)

gma
  • 2,563
  • 15
  • 14
  • That gets me `NameError: no method 'readMetadata' for arguments (java.io.ByteArrayInputStream,org.jruby.RubyBoolean.False) on Java::ComDrewImaging::ImageMetadataReader` – clee May 16 '13 at 08:19