Code example for DataInputStream

Methods: close, readInt, readUnsignedShort

0
 
    private int major;
    private int minor;
     
    public ClassParser(File file) throws IOException{
    	DataInputStream in = new DataInputStream(new FileInputStream(file.getAbsolutePath()));
    	int magic = in.readInt();
        if(magic != 0xcafebabe) {
        	System.out.println(file + " is not a valid class!");;
        } 
        minor = in.readUnsignedShort();
        major = in.readUnsignedShort();
        in.close();
    } 
     
    public int getMajor(){ 
    	return this.major;
    } 
     
    public int getMinor(){ 
    	return this.minor;