private synchronized void rebuildJournal() throws IOException {
  if (mJournalWriter != null) {
    mJournalWriter.close();
  }
  Writer writer=new BufferedWriter(new FileWriter(mJournalFileTmp),IO_BUFFER_SIZE);
  writer.write(MAGIC);
  writer.write("\n");
  writer.write(VERSION_1);
  writer.write("\n");
  writer.write(Integer.toString(mAppVersion));
  writer.write("\n");
  writer.write("\n");
  for (  CacheEntry cacheEntry : mLruEntries.values()) {
    if (cacheEntry.isUnderEdit()) {
      writer.write(sACTION_LIST[ACTION_DIRTY] + ' ' + cacheEntry.getKey()+ " "+ cacheEntry.getSize()+ '\n');
    }
 else {
      writer.write(sACTION_LIST[ACTION_CLEAN] + ' ' + cacheEntry.getKey()+ " "+ cacheEntry.getSize()+ '\n');
    }
  }
  writer.close();
  mJournalFileTmp.renameTo(mJournalFile);
  mJournalWriter=new BufferedWriter(new FileWriter(mJournalFile,true),IO_BUFFER_SIZE);
}

private synchronized void rebuildJournal ( ) throws IOException { if ( mJournalWriter != null ) { mJournalWriter . close ( ) ; } Writer writer = new BufferedWriter ( new FileWriter ( mJournalFileTmp ) , IO_BUFFER_SIZE ) ; writer . write ( MAGIC ) ; writer . write ( "\n" ) ; writer . write ( VERSION_1 ) ; writer . write ( "\n" ) ; writer . write ( Integer . toString ( mAppVersion ) ) ; writer . write ( "\n" ) ; writer . write ( "\n" ) ; for ( CacheEntry cacheEntry : mLruEntries . values ( ) ) { if ( cacheEntry . isUnderEdit ( ) ) { writer . write ( sACTION_LIST [ ACTION_DIRTY ] + ' ' + cacheEntry . getKey ( ) + " " + cacheEntry . getSize ( ) + '\n' ) ; } else { writer . write ( sACTION_LIST [ ACTION_CLEAN ] + ' ' + cacheEntry . getKey ( ) + " " + cacheEntry . getSize ( ) + '\n' ) ; } } writer . close ( ) ; mJournalFileTmp . renameTo ( mJournalFile ) ; mJournalWriter = new BufferedWriter ( new FileWriter ( mJournalFile , true ) , IO_BUFFER_SIZE ) ; }
creates a new journal that omits redundant information . this replaces the current journal if it exists .
