Properties.load会关闭InputStream吗?

Jas*_*son 7 java properties inputstream java-io

我看到了这个例子,但我没有看到close()在 上调用的方法InputStream,所以会prop.load()自动关闭流吗?或者示例中存在错误?

Lyj*_*son 8

Properties.load()之后Stream没有关闭

public static void main(String[] args) throws IOException {

    InputStream in = new FileInputStream(new File("abc.properties"));

    new Properties().load(in);

    System.out.println(in.read());
}
Run Code Online (Sandbox Code Playgroud)

上面的代码返回“-1”,因此流没有关闭。否则它应该抛出java.io.IOException: Stream Closed