Article View: borland.public.jbuilder.java.language
Article #18521RandomAccessFile weirdness
From: angus m. fraser
Date: Fri, 05 Jun 1998 00:00
Date: Fri, 05 Jun 1998 00:00
27 lines
1199 bytes
1199 bytes
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
Technical Details
Message-ID:
<memo.19980605001114.252A@amf.btinternet.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,6e0494f6dbba0af4,start X-Google-Attributes: gidf74b3,public From: java@afraser.cix.co.uk (angus m. fraser) Subject: RandomAccessFile weirdness Date: 1998/06/05 Message-ID: <memo.19980605001114.252A@amf.btinternet.com> X-Deja-AN: 359637362 X-URL: http://www.ameol.com X-News-Software: Ameol2 Reply-To: java@afraser.cix.co.uk Organization: afraser@cix Newsgroups: borland.public.jbuilder.java.language