InputStream to Byte[] ???

J

joealey2003

Hi all...

So, the whole thing i need to do is save an URL on mysql a binary
mysql 4.1 column.
Here goes the non working code...
---------------------------//
URL actual_get = new URL("http://www.myurl.com/");
InputStream Content = (InputStream)actual_get.getContent();

PreparedStatement ps = null;
ps = con.prepareStatement("insert into blobtable values (?)");
ERROR--> ps.setBinaryStream(1,Content,Content.available()); <----ERROR
ps.executeUpdate();
ps.close();
---------------------------//

This code returns many erros like "null pointer exception" or
"Premature EOF"
I am guessing the content.availabe() does not return the value it
should.

How can i write a function InpuStreamToByte(InputStream)?
Using a byte i will have the exactly length and i am guessing i would
avoid these erros.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top