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();
                }
            }
        }
}

 

posted @ 2017-03-28 18:41  zslm___  阅读(211)  评论(0编辑  收藏  举报