private List < SynchroTable > readTableHeaders ( InputStream is ) throws IOException { // Read the headers List < SynchroTable > tables = new ArrayList < SynchroTable > ( ) ; byte [ ] header = new byte [ 48 ] ; while ( true ) { is . read ( header ) ; m_offset += 48 ; SynchroTable table = readTableHeader ( header ) ; if ( table == null ) { break ; } tables . add ( table ) ; } // Ensure sorted by offset Collections . sort ( tables , new Comparator < SynchroTable > ( ) { @ Override public int compare ( SynchroTable o1 , SynchroTable o2 ) { return o1 . getOffset ( ) - o2 . getOffset ( ) ; } } ) ; // Calculate lengths SynchroTable previousTable = null ; for ( SynchroTable table : tables ) { if ( previousTable != null ) { previousTable . setLength ( table . getOffset ( ) - previousTable . getOffset ( ) ) ; } previousTable = table ; } for ( SynchroTable table : tables ) { SynchroLogger . log ( "TABLE" , table ) ; } return tables ; }
Read the table headers . This allows us to break the file into chunks representing the individual tables .