geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Mulder <ammul...@alumni.princeton.edu>
Subject Zip Files and Endian-ness
Date Thu, 04 Nov 2004 18:02:36 GMT
	I'm trying to detect a Zip file.  On an Intel/AMD platform, the 
first 4 bytes are (hex) 50-4b-03-04.  I wonder if the order is different 
on a differently-endian platform.  Can someone look at a ZIP file on, 
what, a Solaris box I guess, and let me know what order the first 4 bytes 
are?  Maybe a Mac is different?  I forget.  Here's a little test class.

Thanks,
	Aaron

import java.io.*;
public class ZipTest {
    public static void main(String[] args) {
        try {
            FileInputStream in = new FileInputStream(args[0]);
            System.out.println("B1: "+Integer.toHexString(in.read()));
            System.out.println("B2: "+Integer.toHexString(in.read()));
            System.out.println("B3: "+Integer.toHexString(in.read()));
            System.out.println("B4: "+Integer.toHexString(in.read()));
            in.close();
            in = new FileInputStream(args[0]);
            System.out.println("Int: "+Integer.toHexString(
                new DataInputStream(in).readInt()));
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

PC Results
----------
B1: 50
B2: 4b
B3: 3
B4: 4
Int: 504b0304

Mime
View raw message