java对iostream的操作很方便的,你自己看看书不就知道了,我也正在看呢

解决方案 »

  1.   

    java.util 
    Class Properties
    java.lang.Object
      |
      +--java.util.Dictionary
            |
            +--java.util.Hashtable
                  |
                  +--java.util.PropertiesDirect Known Subclasses: 
    Provider --------------------------------------------------------------------------------public class Properties
    extends Hashtable
    The Properties class represents a persistent set of properties. The Properties can be saved to a stream or loaded from a stream. Each key and its corresponding value in the property list is a string. A property list can contain another property list as its "defaults"; this second property list is searched if the property key is not found in the original property list. Because Properties inherits from Hashtable, the put and putAll methods can be applied to a Properties object. Their use is strongly discouraged as they allow the caller to insert entries whose keys or values are not Strings. The setProperty method should be used instead. If the store or save method is called on a "compromised" Properties object that contains a non-String key or value, the call will fail. 
      

  2.   

    JAVA程序读取的更多的是属性文件(与INI文件类似,但后缀名是properties),你可以用属性文件来代替。例子:
        FileInputStream in=null;
        Properties props=new Properties();    System.out.println(System.getProperty("user.dir"));    String fileName="info.properties";
        try{
          in=new FileInputStream(fileName);
        }catch(FileNotFoundException fnf)
          {
          fnf.printStackTrace();
          return;
          }
        try{
          props.load(in);
          }catch(IOException ioex)
          {
          ioex.printStackTrace();
           return;
          }    String driver=props.getProperty("jdbc.driver","oracle.jdbc.driver.OracleDriver");
        String url=props.getProperty("jdbc.url","jdbc:oracle:thin:@localhost:1521");
        String user=props.getProperty("jdbc.user","system");
        String password=props.getProperty("jdbc.password","manager");
    属性文件(info.properties)如下:
    jdbc.driver oracle.jdbc.driver.OracleDriver
    jdbc.url jdbc:oracle:thin:@localhost:1521
    jdbc.user system
    jdbc.password manager
      

  3.   

    也就是说可以用读取属性文件的方法读取ini文件
    只要将String fileName="info.properties";
    改成String fileName="info.ini";即可