您是否需要显式关闭Java KeyStore输入流? [英] Do you need to explicity close a Java KeyStore input stream?

查看:87
本文介绍了您是否需要显式关闭Java KeyStore输入流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用FileInputStream如下读取KeyStore时,是否需要显式关闭输入蒸汽以防止浪费系统资源?

When reading in a KeyStore using a FileInputStream as follows, does one need to explicitly close the input-steam to stop system resources being wasted ?

FileInputStream fin = new FileInputStream("keystore.jks");
KeyStore keystore = KeyStore.getInstance("JKS");
keystore.load(fin, password);

//  Is this line needed ??
fin.close();

这个FileInputStream是由load()方法自动关闭的,还是需要显式的手动干预?

Is this FileInputStream closed automatically by the load() method or is explicit manually intervention required?

推荐答案

这个FileInputStream是由load()方法自动关闭的,还是需要显式的手动干预?

Is this FileInputStream closed automatically by the load() method or is explicit manually intervention required?

是的,它需要关闭以解决不必要的泄漏.

yes it required to close to over come unnecessary leaks.

KeyStore的java doc中给出的结帐示例 http://docs.oracle.com/javase/7 /docs/api/java/security/KeyStore.html

Checkout example given in java doc of KeyStore http://docs.oracle.com/javase/7/docs/api/java/security/KeyStore.html

这篇关于您是否需要显式关闭Java KeyStore输入流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆