java读取配置到Hash表里

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Properties;

public class App 
{
    public static void main( String[] args )
    {
        Properties p=new Properties();
        URL resource = App.class.getClassLoader().getResource("application.properties");
        FileInputStream fileInputStream =null;
        try
        {
            fileInputStream = new FileInputStream(resource.getPath());
            p.load(fileInputStream);
        }
        catch (FileNotFoundException ex){
            ex.printStackTrace();
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
        finally {
            if(fileInputStream!=null)
            {
                try {
                    fileInputStream.close();
                }
                catch (IOException ex)
                {
                    ex.printStackTrace();
                }
            }
        }
}
原文地址:https://www.cnblogs.com/zhshlimi/p/6636287.html