commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henri Yandell <bay...@generationjava.com>
Subject [io] EndianUtils....
Date Fri, 02 Jan 2004 07:53:52 GMT

I think the:

    public static long readSwappedLong( InputStream input )
        throws IOException
    {
        int value1 = read( input );
        int value2 = read( input );
        int value3 = read( input );
        int value4 = read( input );
        int value5 = read( input );
        int value6 = read( input );
        int value7 = read( input );
        int value8 = read( input );

        return (long)( ( ( value1 & 0xff ) << 0 ) +
            ( ( value2 & 0xff ) << 8 ) +
            ( ( value3 & 0xff ) << 16 ) +
            ( ( value4 & 0xff ) << 24 ) +
            ( ( value5 & 0xff ) << 32 ) +
            ( ( value6 & 0xff ) << 40 ) +
            ( ( value7 & 0xff ) << 48 ) +
            ( ( value8 & 0xff ) << 56 ) );
    }

code is wrong as it doesn't look like the other readSwappedLong for a
byte[]. I've rewritten it as:

        byte[] bytes = new byte[8];
        input.read( bytes );
        return readSwappedLong( bytes, 0 );

Just in case anyone with a clue has an opinion on the fix.

Hen


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message