Code example for DataInputStream

Methods: readShort

0
   * @param in  
   * @return Metadata Header 
   * @throws IOException 
   */ 
  static BlockMetadataHeader readHeader(DataInputStream in) throws IOException {
    return readHeader(in.readShort(), in);
  } 
   
  /** 
   * Reads header at the top of metadata file and returns the header. 
   *  
   * @param dataset 
   * @param block 
   * @return 
   * @throws IOException 
   */ 
  static BlockMetadataHeader readHeader(File file) throws IOException {
    DataInputStream in = null;
    try { 
      in = new DataInputStream(new BufferedInputStream(
                               new FileInputStream(file)));
      return readHeader(in);
    } finally { 
      IOUtils.closeStream(in);
    } 
  } 
   
  // Version is already read. 
  private static BlockMetadataHeader readHeader(short version, DataInputStream in) 
                                   throws IOException { 
    DataChecksum checksum = DataChecksum.newDataChecksum(in);
    return new BlockMetadataHeader(version, checksum);
  } 
   
  /** 
   * This writes all the fields till the beginning of checksum.