- private void readConfiguration() {
- File configurationFile = new File(filename);
- if (configurationFile.exists()) {
- ByteArrayOutputStream fileByteOutputStream = null;
- FileInputStream fileInputStream = null;
- try {
- fileByteOutputStream = new ByteArrayOutputStream();
- fileInputStream = new FileInputStream(configurationFile);
- StreamCopier.copy(fileInputStream, fileByteOutputStream, configurationFile.length());
- fileByteOutputStream.close();
- byte[] fileBytes = fileByteOutputStream.toByteArray();
- rootNode = SimpleXML.fromDocument(XML.transformToDocument(fileBytes));
- return;
- } catch (FileNotFoundException e) {
- } catch (IOException e) {
- } finally {
- if (fileInputStream != null) {
- try {
- fileInputStream.close();
- } catch (IOException ioe1) {
- }
- }
- if (fileByteOutputStream != null) {
- try {
- fileByteOutputStream.close();
- } catch (IOException ioe1) {
- }
+ /**
+ * Sets the location the configuration will be written to when calling
+ * {@link #save()}.
+ *
+ * @param configurationLocation
+ * The location to write the configuration to
+ */
+ public void setConfigurationLocation(ConfigurationLocation configurationLocation) {
+ this.configurationLocation = configurationLocation;
+ }
+
+ /**
+ * Reads the configuration from the file.
+ *
+ * @param filename
+ * The name of the file to read the configuration from
+ */
+ private void readConfiguration(String filename) {
+ Logger.getLogger(Configuration.class.getName()).log(Level.CONFIG, "Reading configuration from: " + filename);
+ if (filename != null) {
+ File configurationFile = new File(filename);
+ if (configurationFile.exists()) {
+ ByteArrayOutputStream fileByteOutputStream = null;
+ FileInputStream fileInputStream = null;
+ try {
+ fileByteOutputStream = new ByteArrayOutputStream();
+ fileInputStream = new FileInputStream(configurationFile);
+ StreamCopier.copy(fileInputStream, fileByteOutputStream, configurationFile.length());
+ fileByteOutputStream.close();
+ byte[] fileBytes = fileByteOutputStream.toByteArray();
+ rootNode = SimpleXML.fromDocument(XML.transformToDocument(fileBytes));
+ return;
+ } catch (FileNotFoundException e) {
+ /* ignore. */
+ } catch (IOException e) {
+ /* ignore. */
+ } finally {
+ Closer.close(fileInputStream);
+ Closer.close(fileByteOutputStream);