org.tinymediamanager.core.TmmProperties Maven / Gradle / Ivy
/*
* Copyright 2012 - 2019 Manuel Laggner
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.tinymediamanager.core;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Properties;
import java.util.TreeSet;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tinymediamanager.Globals;
/**
* the class TmmProperties is used to store several UI related settings
*
* @author Manuel Laggner
*/
public class TmmProperties {
private final static Logger LOGGER = LoggerFactory.getLogger(TmmProperties.class);
private final static String PROPERTIES_FILE = "tmm.prop";
private static TmmProperties instance;
private Properties properties;
private TmmProperties() {
properties = new Properties();
properties = new Properties();
try (InputStream input = new FileInputStream(new File(Globals.settings.getSettingsFolder(), PROPERTIES_FILE))) {
properties.load(input);
} catch (FileNotFoundException ignored) {
} catch (Exception e) {
LOGGER.warn("unable to read properties file: {}", e.getMessage());
}
}
/**
* the an instance of this class
*
* @return an instance of this class
*/
public synchronized static TmmProperties getInstance() {
if (instance == null) {
instance = new TmmProperties();
}
return instance;
}
private void writeProperties() {
OutputStream output = null;
try {
output = new FileOutputStream(new File(Settings.getInstance().getSettingsFolder(), PROPERTIES_FILE));
Properties tmp = new Properties() {
private static final long serialVersionUID = 1L;
@Override
public synchronized Enumeration
© 2015 - 2025 Weber Informatics LLC | Privacy Policy