Code example for Properties

Methods: clear, getProperty, isEmpty, load

0
    /** Load state from persistent file. Expects sSourcesProperties to be synchronized. */ 
    private void loadLocked() { 
        // Load state from persistent file 
        if (loadProperties()) { 
            // If it lacks our magic version key, don't use it 
            if (sSourcesProperties.getProperty(KEY_VERSION) == null) {
                sSourcesProperties.clear();
            } 
 
            sModified = false;
        } 
 
        if (sSourcesProperties.isEmpty()) {
            // Nothing was loaded. Initialize the storage with a version 
            // identified. This isn't currently checked back, but we might 
            // want it later if we decide to change the way this works. 
            // The version key is choosen on purpose to not match any valid URL. 
            sSourcesProperties.setProperty(KEY_VERSION, "1"); //$NON-NLS-1$ //$NON-NLS-2$
        } 
    } 
 
    /** 
     * Load properties from default file. Extracted so that it can be mocked in tests. 
     * 
     * @return True if actually loaded the file. False if there was an IO error or no 
     *   file and nothing was loaded. 
     */ 
    @VisibleForTesting(visibility=Visibility.PRIVATE) 
    protected boolean loadProperties() { 
        try { 
            String folder = AndroidLocation.getFolder();
            File f = new File(folder, SRC_FILENAME);
            if (f.exists()) {
                FileInputStream fis = null;
                try { 
                    fis = new FileInputStream(f);
                    sSourcesProperties.load(fis);
                } catch (IOException ignore) {
                    // nop 
                } finally { 
                    if (fis != null) {
                        try {