Java Properties Load from File loadMetaConfiguration()

Here you can find the source of loadMetaConfiguration()

Description

Looks for a ".meta" configuration file on the same folder as the FrostWire executable.

License

Open Source License

Return

A Properties object, if the .meta file is not found returns an empty Properties object.

Declaration

public static Properties loadMetaConfiguration() 

Method Source Code


//package com.java2s;
/*//from   www  .j  av a2 s  .c  om
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import java.util.Properties;

public class Main {
    /**
     * Looks for a ".meta" configuration file on the same folder as the FrostWire executable.
     * If found this file should contain the following configuration values:
     * 
     * user.settings.dir.windows = <relative path to frostwire settings directory for windows installation>
     * user.settings.dir.mac = <relative path to frostwire settings directory for windows installation>
     * user.settings.dir.posix = <relative path to frostwire settings directory for posix installation>
     * 
     * @return A Properties object, if the .meta file is not found returns an empty Properties object.
     */
    public static Properties loadMetaConfiguration() {
        Properties meta = new Properties();

        File metaFile = new File(".meta");
        if (metaFile.exists() && metaFile.isFile() && metaFile.canRead()) {
            FileInputStream fis = null;
            try {
                fis = new FileInputStream(metaFile);
                meta.load(fis);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                closeQuietly(fis);
            }
        }

        return meta;
    }

    public static void closeQuietly(Closeable closeable) {
        try {
            if (closeable != null) {
                closeable.close();
            }
        } catch (IOException ioe) {
            // ignore
        }
    }
}

Related

  1. loadLibrarySmart(String libraryName)
  2. loadLocalization(final ZipFile file, final String loc)
  3. loadLocatorInfo(String fileName)
  4. loadLWJGL()
  5. loadManifest(File bundleLocation)
  6. loadMimeTypes(InputStream inputStream)
  7. loadNative(File nativeLibsFolder)
  8. loadNecessaryPackagePrivateProperties(Class aClass, String aFileName)
  9. loadOSDependentLibrary()