Java.io.FileInputStream.finalize() 方法 Java.io.FileInputStream.close() 方法 Java.io.FilePermission.equals() 方法 Java.io.FileInputStream.finalize() 方法 package com.codingdict; import java.io.FileInputStream; import java.io.IOException; public class FileInputStreamAvailable extends FileInputStream { public FileInputStreamAvailable() throws Exception { super("C://test.txt"); } public static void main(String[] args) throws IOException { FileInputStream fis = null; int i; char c; try { // create new File input stream FileInputStreamAvailable fisa = new FileInputStreamAvailable(); // read byte from file input stream i=fisa.read(); // converts int to char c = (char)i; // prints character System.out.println(c); // finalize method invoked fisa.finalize(); // method revoked after finalize metod i = fisa.read(); c = (char)i; System.out.println(c); } catch(Exception ex) { // if any error occurs System.out.print("Error: read() invoked after finalize()"); } finally { // releases all system resources from the streams if(fis!=null) fis.close(); } } } Java.io.FileInputStream.close() 方法 Java.io.FilePermission.equals() 方法