JAVA读取ini文件(很简单不带section)

来源:互联网 发布:wifi监控摄像头软件 编辑:程序博客网 时间:2024/04/29 08:25
import java.io.*;  import java.util.Properties;    public class IniReader {   public  Properties ini = null;      public  IniReader(String fileString)     {        File file=new File(fileString);          try         {              ini = new Properties ();              ini.load (new FileInputStream (file));          }        catch (Exception ex)         {              ex.printStackTrace();          }     }       public  String getIniKey (String key) {          if(!ini.containsKey (key))         {              return null;          }          return ini.get(key).toString();      }        public static void main(String[] args)    {     IniReader ini=new IniReader("D:\\sendSMS\\conn.ini");     System.out.println(ini.getIniKey("driver"));    }}