🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: RandomAccessFile weirdness

#18523
From: Rich Wilkman
Date: Fri, 05 Jun 1998 00:00
53 lines
2078 bytes
Angus:

You're probably getting a "big indian, little indian" issue here. 
When I was reading ints from a binary file I had to remember to
bitshift them because they're different in Java (to get around the
lack of a "signed" keyword).

-Rich

angus m. fraser wrote:
> 
> Hi,
> 
> This might be just me not understanding Java properly but...
> 
> I'm reading shorts out of a binary file using something like this.
> 
> try {
>   File f = new File("c:\\pc-cora\\archive\\98040111.edt");
>   RandomAccessFile r  = new RandomAccessFile(f, "r");
>   r.seek(82);
>   short s = r.readShort();
>   ...
>   }
> 
> The problem is this is that 'short s' is giving the wrong answer. I've
> checked the 2 bytes being read(using readByte) and they are correct.
> 
> It seems the conversion from 2 chars/bytes to a short(in
> RandomAccessFile.readShort() ) is wrong, at least compared to the
> short(smallint) value properly returned by Delphi.
> 
> Anyone shed any light on this?
> 
> --
> Angus Fraser
> afraser@cix.co.uk

-- 

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Rich Wilkman
Senior Quality Assurance Engineer
Borland JBuilder Team

If you see something that looks like an opinion up there,
it's mine and mine alone.

Mail sent to me from the newsgroups won't bounce but will
be ignored.  If I have time, I'll respond, but you  have
a better chance if you confine your posts to the newsgroups
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Technical Details
Message-ID: <35781FFA.4E08492E@corp.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <memo.19980605001114.252A@amf.btinternet.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,6e0494f6dbba0af4
X-Google-Attributes: gidf74b3,public
From: Rich Wilkman <rwilkman@corp.borland.com>
Subject: Re: RandomAccessFile weirdness
Date: 1998/06/05
Message-ID: <35781FFA.4E08492E@corp.borland.com>
X-Deja-AN: 359876330
Content-Transfer-Encoding: 7bit
References: <memo.19980605001114.252A@amf.btinternet.com>
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language