Code example for DataInputStream

Methods: readByte, readInt, readUTF

0
     * @param in the stream to read from 
     * @return the new version 
     * @throws IOException if an error occurs or the format is unknown 
     */ 
    public static Version read( DataInputStream in ) throws IOException{
        byte version = in.readByte();
        if( version != 1 )
            throw new IOException( "Unknown format for version" );
        int major = in.readInt();
        int minor = in.readInt();
        int mikro = in.readInt();
        String add = in.readUTF();
        return new Version( major, minor, mikro, add );
    } 
     
    /** 
     * Checks whether this version is greater than the current version and 
     * throws an exception if so. This method is intended to be called from code 
     * that is loading some file, but other usages are possible as well. 
     * @throws IOException thrown if the current version is smaller than <code>this</code>. 
     */