[2699] in java-interest
Re: Dealing with byte[]s
daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Tue Oct 10 23:12:15 1995
Date: Tue, 10 Oct 1995 18:30:24 -0700
From: Arthur.Vanhoff@Eng.Sun.COM (Arthur van Hoff)
To: mikea@ai.mit.edu
Cc: java-interest@java.Eng.Sun.COM
Hi Mike,
> Where do bytes fit into the general Java scheme of things?
> They're not even defined under java.lang. Where did their need come
> from?
>
> Basically, I have two very related problems:
>
> I'm reading some info from a InputStream and want to treat the
> info as a String. How can I convert one to the other?
Try readLine() in the DataInputStream class.
> Furthermore, if for testing purposes I wish to explicitly
> create an array of bytes, what is the syntax? I declare it at the top
> of my program. How do I allocate memory for it? (I assume: line =
> new byte[123].) More importantly, how do I specify its contents?
You have to declare:
byte b[] = new byte[123];
or you can write:
byte b[] = { 0, 1, 2, 3, 4, 5};
Have fun,
Arthur van Hoff
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com