62,623
社区成员
发帖
与我相关
我的任务
分享public static void main(String[] args) throws IOException {
Properties p = new Properties();
p.setProperty("Name", "web7715367");
p.setProperty("Name2", "web7715368");
OutputStream os = new FileOutputStream("ini.ini");
p.store(os, null);
os.close();
}
package cn.csu.edu.collection.vo;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
public class TestIni {
public String readValue(String filePath, String key) {
Properties props = new Properties();
try {
InputStream in = new BufferedInputStream(new FileInputStream(filePath));
System.out.println(in);
props.load(in);
String value = props.getProperty(key);
System.out.println(key + value);
return value;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
TestIni ts = new TestIni();
ts.readValue("ini.ini", "qq");
}
}