import java.util.*;
import java.io.*;
class SystemInfo
{
public static void main(String[] args) throws IOException
{
Properties prop = System.getProperties();
//System.out.println(prop);
prop.list( new PrintStream("sysinfo.txt")
}
}
上面的红的那里 为什么不能是FileOutputStream() 只是因为API就这么规定的吗?
作者: 为梦而战 时间: 2011-12-24 16:25
你有没有用new啊?比如:new FileOutputStream("sysinfo.txt")作者: 李楠 时间: 2011-12-24 18:52
void list(PrintWriter out)
Lists the mappings in this Properties to out in a human-readable form.
void list(PrintStream out)
Lists the mappings in this Properties to out in a human-readable form.
给你看一下list的函数原型,只能使用PrintWriter,PrintStream这两种类型的形参。
API就是这么规定的。
prop.list( new PrintStream("sysinfo.txt") //少了个括号。