🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16195

Re: Byte swapping

#16195
From: Steve Schafer (TeamB)
Date: Tue, 16 Mar 1999 00:00
27 lines
1587 bytes
On Tue, 16 Mar 1999 12:00:51 -0700, Doug Bath <dbath@agt.net> wrote:

>Thanks for confirming my worst fears. In this case it isn't a show stopper
>since I am writing this app mostly for internal use and most of the data I am
>working with is big endian with IEEE float values. However it means that I can
>forget about writing a commercial app since that functionality has to be there.

>This is the second major limitation I have encountered in Java

You're being far too pessimistic. Just because it won't work the way
you originally envisioned doesn't mean it can't be done. Here's a
general approach:

1) Instantiate a byte array, big enough to hold one of the values
whose bytes you want to swap.

2) Instantiate a ByteArrayOutputStream on those bytes.

3) Write the value to be converted to the stream.

4) Swap the bytes around in the byte array as desired.

5) Instantiate a ByteArrayInputStream on the bytes.

6) Read the converted value from the stream.

-Steve
Technical Details
Message-ID: <3779b5bb.478259775@90.0.0.40>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36EE8AA3.3212A98D@agt.net> <7cm785$4dq26@forums.borland.com> <36EEAA63.C25717AC@agt.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,a228e969071f0feb
X-Google-Attributes: gidf74b3,public
From: pandeng@telepath.com (Steve Schafer (TeamB))
Subject: Re: Byte swapping
Date: 1999/03/16
Message-ID: <3779b5bb.478259775@90.0.0.40>
X-Deja-AN: 455733065
Content-Transfer-Encoding: 7bit
References: <36EE8AA3.3212A98D@agt.net> <7cm785$4dq26@forums.borland.com> <36EEAA63.C25717AC@agt.net>
Content-Type: text/plain; charset=us-ascii
Organization: TeamB
Mime-Version: 1.0
Reply-To: pandeng@telepath.com
Newsgroups: borland.public.jbuilder.java.language