当使用FileInputStream在KeyStore中读取如下时,是否需要显式关闭input-steam以停止浪费系统资源?
FileInputStream fin = new FileInputStream("keystore.jks"); KeyStore keystore = KeyStore.getInstance("JKS"); keystore.load(fin,password); // Is this line needed ?? fin.close();
解决方法
Is this FileInputStream closed automatically by the load() method or is explicit manually intervention required?
是的,它需要接近结束不必要的泄漏.
KeyStore的java doc中给出的Checkout示例
http://docs.oracle.com/javase/7/docs/api/java/security/KeyStore.html