public static void write(String filename) throws IOException, Exception{ BufferedReader br = new BufferedReader(new FileReader(filename));
public static void write(String filename) throws IOException, Exception{
	public static void write(String filename) throws IOException, Exception{        BufferedReader br = new BufferedReader(new FileReader(filename));        BufferedWriter bw;        Vector inputLines = new Vector();        HashMap availableKeys = new HashMap();        String line;        while((line = br.readLine()) != null) {            inputLines.add(line);        }        br.close();        bw = new BufferedWriter(new FileWriter(filename));        Iterator lineItr = inputLines.iterator();        while (lineItr.hasNext()) {            line = (String)lineItr.next();            // Make sure it isn't a comment            if (!line.trim().startsWith("#") && line.trim().length() > 0) {				String [] keyValue = line.split("[ ]*=[ ]*");				availableKeys.put(keyValue[0], "Tiled is cool");				if (hasOption(keyValue[0])) {                    String newLine = line.substring(0, line.lastIndexOf(                                keyValue[1])) + getValue(keyValue[0]);                    bw.write(newLine);                    bw.newLine();                } else {                    bw.write(line);                    bw.newLine();                }            } else {                bw.write(line);                bw.newLine();            }        }        bw.newLine();        Iterator keyItr = settings.keySet().iterator();        while (keyItr.hasNext()) {            String key = (String)keyItr.next();            try {                if (availableKeys.get(key) == null){                    if (settings.get(key) != null) {                        bw.write(key + " = " + settings.get(key));                        bw.newLine();                    }                }            } catch (Exception e) {                if (settings.get(key) != null) {                    bw.write(key + " = " + settings.get(key));                    bw.newLine();                }            }        }        bw.close();    }