[1107] in java-interest
Re: Network Byte Stream to Integers
daemon@ATHENA.MIT.EDU (Thomas Ball)
Fri Aug 18 20:38:30 1995
Date: Fri, 18 Aug 1995 14:46:56 -0700
From: Thomas.Ball@Eng.Sun.COM (Thomas Ball)
To: sid.conklin@nora.stanford.edu
Cc: java-interest@java.Eng.Sun.COM
> I can't find an easy way to take a byte stream and parse it into Integers. I
> have a middle service this is return me a packed C structure:
>
> unsigned short(1) ServiceCmdPort
> unsigned short(1) ServiceCmdPort
> unsigned long(2) ServicePID
> ...
>
> 1: short = 2 bytes
> 2: long = 4 bytes
>
> I'm using an inputStream for the read(inputStreamByte).
{
DataInputStream in = new DataInputStream(
new BufferedInputStream(some_InputStream_instance));
short ServiceCmdPort1 = in.readShort();
short ServiceCmdPort2 = in.readShort();
int ServicePID[] = int[2];
ServicePID[0] = in.readInt();
ServicePID[1] = in.readInt();
}
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com