@Nullable
  public byte[] getBitmap(RandomAccessFile raf) throws IOException {
    if (startingPosition <= 0) {
      throw new IllegalStateException("Grib1 Bit map has bad starting position");
    }

    raf.seek(startingPosition);

    // octet 1-3 (length of section)
    int length = GribNumbers.uint3(raf);

    // octet 4 unused bits
    raf.read();   // unused

    // octets 5-6
    int bm = raf.readShort();
    if (bm != 0) {
      logger.warn("Grib1 Bit map section pre-defined (provided by center) bitmap number = {}", bm);
      return null;
    }

    // not sure if length is set correctly when pre-define bitmap is used, so  wait until that to test
    // seeing a -1, bail out
    if (length <= 6 || length > 10e6) {   // look max  ??
      return null;
    }

    // read the bits as integers
    int n = length - 6;
    byte[] data = new byte[n];
    raf.readFully(data);
    return data;
  }
@Nullable
  public byte[] getBitmap(RandomAccessFile raf) throws IOException {
    if (startingPosition <= 0) {
      throw new IllegalStateException("Grib1 Bit map has bad starting position");
    }

    raf.seek(startingPosition);

    
    int length = GribNumbers.uint3(raf);

    
    raf.read();   

    
    int bm = raf.readShort();
    if (bm != 0) {
      logger.warn("Grib1 Bit map section pre-defined (provided by center) bitmap number = {}", bm);
      return null;
    }

    
    
    if (length <= 6 || length > 10e6) {   
      return null;
    }

    
    int n = length - 6;
    byte[] data = new byte[n];
    raf.readFully(data);
    return data;
  }
@ Nullable public byte [ ] getBitmap ( RandomAccessFile raf ) throws IOException { if ( startingPosition <= 0 ) { throw new IllegalStateException ( "Grib1 Bit map has bad starting position" ) ; } raf . seek ( startingPosition ) ; // octet 1-3 (length of section)
 int length = GribNumbers . uint3 ( raf ) ; // octet 4 unused bits
 raf . read ( ) ; // unused
 // octets 5-6
 int bm = raf . readShort ( ) ; if ( bm != 0 ) { logger . warn ( "Grib1 Bit map section pre-defined (provided by center) bitmap number = {}" , bm ) ; return null ; } // not sure if length is set correctly when pre-define bitmap is used, so  wait until that to test
 // seeing a -1, bail out
 if ( length <= 6 || length > 10e6 ) { // look max  ??
 return null ; } // read the bits as integers
 int n = length - 6 ; byte [ ] data = new byte [ n ] ; raf . readFully ( data ) ; return data ; }
Read the bitmap array when needed, return null if none.
Read the bitmap array when needed return null if none .