Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to initialize byte array

807598Oct 29 2006 — edited Oct 29 2006
Hi,

I want to do :
byte[] byteArray = null;

someInputStream.read(byteArray);
But I get a NullPointerException from byteArray being null. So I changed it to:
byte[] byteArray;

someInputStream.read(byteArray);
But my IDE ( Eclipse ) won't let me compile saying the variable byteArray has not been initialized.

What I want to do is create a byte array that can be used by the read method. How do I do this ?
One more question, can I do this without knowing the size of the array before hand ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 26 2006
Added on Oct 29 2006
1 comment
3,460 views