Java Properties Load from File loadPropertiesFromFile(JarFile jar)

Here you can find the source of loadPropertiesFromFile(JarFile jar)

Description

load Properties From File

License

Open Source License

Declaration

public static Map<String, String> loadPropertiesFromFile(JarFile jar) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.io.InputStream;

import java.util.Enumeration;
import java.util.HashMap;

import java.util.Map;
import java.util.Properties;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

public class Main {
    public static Map<String, String> loadPropertiesFromFile(JarFile jar) throws IOException {
        Map<String, String> result = new HashMap<String, String>();
        Properties props = new Properties();
        JarEntry entry = jar.getJarEntry("conf/plugin.properties");
        if (entry != null) {
            InputStream in = jar.getInputStream(entry);
            props.load(in);/*from  w  w w.  j  a va2 s . c o m*/
            Enumeration<?> en = props.propertyNames();
            while (en.hasMoreElements()) {
                String key = en.nextElement().toString().trim();
                result.put(key, props.getProperty(key, ""));
            }
        }
        return result;
    }
}

Related

  1. loadPropertiesFile(String propFilePath)
  2. loadPropertiesFromClasspath( final String filename)
  3. loadPropertiesFromClasspath(Class loadResourceClass, String classpath)
  4. loadPropertiesFromClasspath(String pfname)
  5. loadPropertiesFromFile(Class clazz, String filePath)
  6. loadPropertiesFromFile(String configFile)
  7. loadPropertiesFromFile(String filePath)
  8. loadPropertiesFromFile(String fullFileName)
  9. loadPropertiesFromFile(String pathname)