Java Properties Load loadProperties()

Here you can find the source of loadProperties()

Description

load Properties

License

LGPL

Declaration

private static Properties loadProperties() 

Method Source Code

//package com.java2s;
/*/* ww  w . j ava 2s .c o  m*/
 * License GNU LGPL
 * Copyright (C) 2012 Amrullah <amrullah@panemu.com>.
 */

import java.io.File;
import java.io.FileInputStream;

import java.io.IOException;

import java.util.Properties;

public class Main {
    private static String applicationId = ".tiwulfx";

    private static Properties loadProperties() {
        Properties p = new Properties();
        try {
            FileInputStream in = new FileInputStream(getConfigurationPath());
            p.load(in);
            in.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return p;

    }

    private static String getConfigurationPath() throws IOException {
        String home = System.getProperty("user.home");

        String confPath = home + File.separator + applicationId;

        File confFile = new File(confPath);
        if (!confFile.exists()) {
            confFile.mkdirs();
        }
        confPath = home + File.separator + applicationId + File.separator
                + "conf.properties";
        confFile = new File(confPath);
        if (!confFile.exists()) {
            confFile.createNewFile();
        }
        return confPath;
    }
}

Related

  1. loadProperties()
  2. loadProperties()
  3. loadProperties()
  4. loadProperties()
  5. loadProperties()