您的位置:首页 > 编程语言 > Java开发

java.util.Properties读取properties文件

2016-01-21 10:16 441 查看
        Properties prop = new Properties();

        InputStream inStream = null;

        

        try
        {

           //具体路径

            inStream = new FileInputStream("......//typeMap.properties");
            prop.load(inStream);

            Enumeration<String> e = (Enumeration<String>)prop.propertyNames();

        

            String key = null;

          String value = null;

          String[] values = null;

          boolean hasMoreElements = e.hasMoreElements();

          while (hasMoreElements)

          {

              key = (String)e.nextElement();

              value = prop.getProperty(key);

            

           

             hasMoreElements = e.hasMoreElements();

          }

        }

        catch (FileNotFoundException e1)

        {

           //todo

        }

        catch (IOException e1)

        {

            //todo

        }

        finally

        {

            try

            {

                    if (null != inStream)

                    {

                        inStream.close();

                    }

            }

                catch (IOException e1)

                {

                    //todo

                }

        }

        

      
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: