小编nor*_*ori的帖子

do i need call close() on every new inputstream?

here is the code.

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

    FileInputStream fis = null;

    fis = new FileInputStream(new File("D:\\za180s.ser"));
    // do something
    fis = new FileInputStream(new File("D:\\za185s.ser"));
    // do something
    fis = new FileInputStream(new File("D:\\za186s.ser"));
    // do something
    fis = new FileInputStream(new File("D:\\za187s.ser"));
    // do something
    fis.close();

}
Run Code Online (Sandbox Code Playgroud)

the problem is : need i call fis.close() method after every "do something" or i just call fis.close() once after all.

ignore whether the close() position in finally and the …

java inputstream

1
推荐指数
1
解决办法
67
查看次数

标签 统计

inputstream ×1

java ×1