blob: 9f90fb61c6edea9d9850e1e9d812364dc6806956 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*
* Copyright 2012 Jesse Morgan
*/
package net.jesterpm.podcastuploader.model;
import java.io.*;
import java.text.ParseException;
import java.util.Map;
import java.util.HashMap;
import java.util.Properties;
/**
* Configuration and metadata parser.
*
* @author Jesse Morgan <jesse@jesterpm.net>
*/
public class Config extends Properties {
private static final String COMMENT = "Podcast Uploader Configuration";
private final String mFilename;
/**
* Create a new Config object based on the given file.
*/
public Config(final String filename) throws IOException {
mFilename = filename;
load();
}
/**
* Load the config file.
*
* @throws IOException
*/
public void load() throws IOException {
try {
final FileReader reader = new FileReader(mFilename);
load(reader);
} catch (FileNotFoundException e) {
// No big deal, just start with an empty config.
}
}
/**
* Save the config file.
*
* @throws IOException
*/
public void save() throws IOException {
final FileWriter writer = new FileWriter(mFilename);
store(writer, COMMENT);
}
}
|