Changeset 20 in josm for src/org/openstreetmap/josm/data


Ignore:
Timestamp:
2005-10-13T08:27:12+02:00 (19 years ago)
Author:
imi
Message:

Added bookmarks for importing and fixed password dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/data/Preferences.java

    r18 r20  
    66import java.io.FileReader;
    77import java.io.FileWriter;
     8import java.io.IOException;
    89import java.util.Collection;
    910import java.util.LinkedList;
     
    7980         * Return the location of the preferences file
    8081         */
    81         public static String getPreferencesFile() {
    82                 return System.getProperty("user.home")+"/.josm-preferences";
     82        public static String getPreferencesDir() {
     83                return System.getProperty("user.home")+"/.josm/";
    8384        }
    8485       
     
    9192                        super(message, cause);
    9293                }
     94                public PreferencesException(String message) {
     95                        super(message);
     96                }
    9397        }
    9498        /**
     
    97101         */
    98102        public void load() throws PreferencesException {
    99                 File file = new File(System.getProperty("user.home")+"/.josm-preferences");
     103                File file = new File(getPreferencesDir()+"/preferences");
    100104                Element root;
    101105                try {
     
    159163
    160164                try {
    161                         final FileWriter file = new FileWriter(getPreferencesFile());
     165                        File prefDir = new File(getPreferencesDir());
     166                        if (prefDir.exists() && !prefDir.isDirectory())
     167                                throw new PreferencesException("Preferences directory "+getPreferencesDir()+" is not a directory.");
     168                        if (!prefDir.exists())
     169                                prefDir.mkdirs();
     170
     171                        FileWriter file = new FileWriter(getPreferencesDir()+"/preferences");
    162172                        new XMLOutputter(Format.getPrettyFormat()).output(root, file);
    163173                        file.close();
    164                 } catch (Exception e) {
     174                } catch (IOException e) {
    165175                        throw new PreferencesException("Could not write preferences", e);
    166176                }
Note: See TracChangeset for help on using the changeset viewer.