Re: [jruby-user] Reading binary Files

Ariel Valentin <[email protected]>
Newsgroups gmane.comp.lang.jruby.user
Message-ID <CAKthdGgXr7XoY0LK-2zwq1eduC-S=w9R+T3im8Y3k2p7zEH13g@mail.gmail.com>
Would you mind clarifying your goal a little. Is it your intention to read
the bytes in a "streaming" fashion or is it OK to read the entire file in
memory as a byte[]?



Ariel Valentin
e-mail: [email protected]
website: http://blog.arielvalentin.com
skype: ariel.s.valentin
twitter: arielvalentin
linkedin: http://www.linkedin.com/profile/view?id=8996534
---------------------------------------
*simplicity *communication
*feedback *courage *respect

On Sat, Oct 4, 2014 at 5:38 PM, Roger Palma <[email protected]> wrote:

> Hi there
> I am trying to read a binary file using Java's "FileInputStream" to
> later store it in HBase.
>
> My problem is the byte-array conversion needed to call the read-method:
>
> inFile = File.new("/home/roger/Downloads/test.jpg")
> inputStream = FileInputStream.new(inFile)
>
> length = inFile.length()
> buffer = ""
>
> inputStream.read(buffer)
>
>
> Any Ideas?
>
> You may find the entire code in the attachment.
>
> Thanks
> Roger
>
> Attachments:
> http://www.ruby-forum.com/attachment/10139/test.rb
>
>
> --
> Posted via http://www.ruby-forum.com/.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.