예제 #1
0
  protected static Header readHeader(DataInput in) throws Exception {
    short magic_number = in.readShort();
    Class clazz = ClassConfigurator.get(magic_number);
    if (clazz == null)
      throw new IllegalArgumentException(
          "magic number " + magic_number + " is not available in magic map");

    Header hdr = (Header) clazz.newInstance();
    hdr.readFrom(in);
    return hdr;
  }
예제 #2
0
  private static Header readHeader(DataInputStream in) throws IOException {
    try {
      short magic_number = in.readShort();
      Class clazz = ClassConfigurator.get(magic_number);
      if (clazz == null)
        throw new IllegalArgumentException(
            "magic number " + magic_number + " is not available in magic map");

      Header hdr = (Header) clazz.newInstance();
      hdr.readFrom(in);
      return hdr;
    } catch (Exception ex) {
      IOException io_ex = new IOException("failed reading header");
      io_ex.initCause(ex);
      throw io_ex;
    }
  }