Java Properties Load from File load(String file)

Here you can find the source of load(String file)

Description

Loads properties by given file

License

Open Source License

Parameter

Parameter Description
file filename

Exception

Parameter Description

Return

loaded properties

Declaration

public static Properties load(String file) throws IOException 

Method Source Code

//package com.java2s;
/**/*from  w  ww  .j ava  2 s  . co  m*/
 * This file is part of Aion X Emu <aionxemu.com>
 *
 *  This is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This software 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 Lesser Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser Public License
 *  along with this software.  If not, see <http://www.gnu.org/licenses/>.
 */

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

import java.util.Properties;

public class Main {
    /**
     * Loads properties by given file
     *
     * @param file filename
     * @return loaded properties
     * @throws java.io.IOException if can't load file
     */
    public static Properties load(String file) throws IOException {
        return load(new File(file));
    }

    /**
     * Loads properties by given file
     *
     * @param file filename
     * @return loaded properties
     * @throws java.io.IOException if can't load file
     */
    public static Properties load(File file) throws IOException {
        FileInputStream fis = new FileInputStream(file);
        Properties p = new Properties();
        p.load(fis);
        fis.close();
        return p;
    }

    /**
     * Loades properties from given files
     *
     * @param files list of string that represents files
     * @return array of loaded properties
     * @throws IOException if was unable to read properties
     */
    public static Properties[] load(String... files) throws IOException {
        Properties[] result = new Properties[files.length];
        for (int i = 0; i < result.length; i++) {
            result[i] = load(files[i]);
        }
        return result;
    }

    /**
     * Loades properties from given files
     *
     * @param files list of files
     * @return array of loaded properties
     * @throws IOException if was unable to read properties
     */
    public static Properties[] load(File... files) throws IOException {
        Properties[] result = new Properties[files.length];
        for (int i = 0; i < result.length; i++) {
            result[i] = load(files[i]);
        }
        return result;
    }
}

Related

  1. load(Properties properties, String fileName)
  2. load(Properties props, Collection filters, File basedir)
  3. load(Properties props, File f)
  4. load(Properties props, File file)
  5. load(Properties props, String filename)
  6. load(String file)
  7. load(String filename)
  8. load(String filename)
  9. load(String fileName)