public synchronized void read ( ) throws IOException { if ( ! validState ) { throw new InvalidStateException ( ) ; } final long offset = ( ( fc . size ( ) & ~ 7 ) - 8 ) ; if ( offset < 0 ) { throw new IOException ( "Empty file" ) ; } buf . clear ( ) ; int readed = fc . position ( offset ) . read ( buf ) ; if ( readed < 8 ) { // long 8 bytes throw new IOException ( "cant read long from file" ) ; } buf . flip ( ) ; value = buf . getLong ( ) ; }
Read value from file