package fatread;
import java.io.RandomAccessFile ;

public class FATread {

    public static void main(String[] args) {
        try {
            RandomAccessFile binFile = new RandomAccessFile("boot.img", "r") ;
            byte[] sector = new byte[512] ;
            binFile.read(sector) ;
            System.out.println("Number of FAT blocks: " +
                    ((0xFF & sector[23]) << 8) + (0xFF & sector[22])) ;
            int num_blocks = 
                    ((sector[35] & 0xFF) << 24) + ((sector[34] & 0xFF) << 16)
                    + ((sector[33] & 0xFF) << 8) + (sector[32] & 0xFF)  ;
            System.out.println("Total of all  blocks: " + num_blocks) ;
        } catch (Exception e) {
            System.err.println("Oops" + e) ;
        }
    }
    
}
