if ( scratch_file_is == null || messages_dirty ){
File temp_file = null;
FileOutputStream fos = null;
// we have a previous cache, discard
if ( scratch_file_is != null ){
// System.out.println( "discard cache file " + scratch_file_name + " for " + this );
try{
scratch_file_is.close();
}catch( Throwable e ){
scratch_file_name = null;
}finally{
scratch_file_is = null;
}
}
try{
Properties props = new Properties();
props.putAll( messages );
if ( scratch_file_name == null ){
temp_file = AETemporaryFileHandler.createTempFile();
}else{
temp_file = scratch_file_name;
}
fos = new FileOutputStream( temp_file );
props.store( fos, "message cache" );
fos.close();
fos = null;
// System.out.println( "wrote cache file " + temp_file + " for " + this );
scratch_file_name = temp_file;
scratch_file_is = new FileInputStream( temp_file );
messages_dirty = false;
}catch( Throwable e ){
if ( fos != null ){
try{
fos.close();
}catch( Throwable f ){
}
}