在vb,vc中,类似生明
VB声明 
  Declare Function GetPrivateProfileString& Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) 
    可以调用GetPrivateProfileString这个API。。方便的读取ini文件中的值。。    在java中,如何使用这样的API

解决方案 »

  1.   


    test.java
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.util.Properties;public class TestIni { public static void main(String[] args) {
    Properties  prop  =  new  Properties(); 
            try{ 
                prop.load(new FileInputStream("E:/test.ini")); 
             String value  =  prop.getProperty("ty_fzpb"); 
                System.out.println(value);
            }catch(IOException e){
             e.printStackTrace();
            }
    }
    }
    test.ini文件内容如下:
    ty_fzpb=local
      

  2.   

    非常感谢。。不过当ini中有相同的两个key时,它只会找倒最后一个?
    如果有两个我如何区分。。
    例如ini中如下内容:
    [aa]
    hello=helloaa
    [bb]
    hello=hellobb我怎么读取[aa]中,hello的值。。
      

  3.   

    http://topic.csdn.net/u/20070920/10/fb623410-017f-4615-bb46-50e5f1078a1d.html