public void save ( File file , String comment , boolean saveDefaults , String propertyName ) throws IOException { gatekeeper . lock ( ) ; try { File parent = file . getParentFile ( ) ; if ( ! parent . exists ( ) && ! parent . mkdirs ( ) ) { throw new IOException ( "Directory at \"" + parent . getAbsolutePath ( ) + "\" does not exist and cannot be created" ) ; } FileOutputStream outputStream = new FileOutputStream ( file ) ; try { Properties tmpProperties = getProperties ( saveDefaults , propertyName ) ; tmpProperties . store ( outputStream , comment ) ; /* * If we only saved a single property, only that property should * be marked synced. */ if ( propertyName != null ) { properties . get ( propertyName ) . synced ( ) ; } else { for ( ChangeStack < String > stack : properties . values ( ) ) { stack . synced ( ) ; } } } finally { outputStream . close ( ) ; } } finally { gatekeeper . unlock ( ) ; } }
Save the current state of the given property to the given file without saving all of the other properties within this instance .