用Java编写:

2025-05-20 20:47:27
推荐回答(3个)
回答1:

我组你一个例子程序吧.
//以下是my.ini的文件内容
company=cie
author=ljb
copyright=2006-2007
//以下是读取这个文件的源代码
import java.io.*;
import java.util.*;

public class PropTest
{
public static void main(String[] args)
{
// TODO 自动生成方法存根
Properties ps = new Properties();
try
{
ps.load(new FileInputStream("my.ini"));
Enumeration en = ps.propertyNames();

while (en.hasMoreElements())
{
String strKey = (String) en.nextElement();
String strValue = ps.getProperty(strKey);

System.out.println(strKey + " : " + strValue);
}
}
catch (Exception e)
{
// TODO: handle exception
e.printStackTrace();
}
}
}

回答2:

用BufferedReader和FileReader 写就好了!!

回答3:

使用文本流对象就可以了。JAVA初级教程一般都有事例