🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.lenguajes.java
Article #28264

Re: Q: Lectura de fiechero binario

#28264
From: manuel
Date: Tue, 12 May 1998 00:00
34 lines
1199 bytes
Hola,

>[...]
>Utilizando el programa java:
>
>int lsb, msb;
>int a�o;
>
>InputStream fich = new FileInputStream( "97280a14.hrp" ); 
>DataInputStream in = new DataInputStream( fich );
>
>lsb = (int)in.readByte();
>msb = (int)in.readByte();
>a�o = ( (msb * 256) + lsb );
>System.out.println( "lsb: " + lsb );
>System.out.println( "msb: " + msb );
>System.out.println( "A�o: " + a�o );
>
>obtengo como resultado:
>
>lsb: -51
>msb: 7
>A�o: 1741
>
>que no es lo que quiero. Supongo que el problema esta en que readByte supone

Prueba esto:

b1=(byte)in.readUnsignedByte();
b2=(byte)in.readUnsignedByte();
a�o = ( b2 * 256) + b1 );

Un saludo.
Technical Details
Message-ID: <3557738f.7011281@diana.ibernet.es>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6j6l7k$qvb$2@erika.cica.es>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 1116f3,755beee34340d88a
X-Google-Attributes: gid1116f3,public
From: javadist@geocities.com (manuel)
Subject: Re: Q: Lectura de fiechero binario
Date: 1998/05/12
Message-ID: <3557738f.7011281@diana.ibernet.es>
X-Deja-AN: 352492950
Content-Transfer-Encoding: 8bit
References: <6j6l7k$qvb$2@erika.cica.es>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Organization: Telefonica Transmision de Datos
Newsgroups: es.comp.lenguajes.java