close(): This method is available in the java.io.FileInputStream class of Java.
Syntax:
void java.io.FileInputStream.close() throws IOException
This method closes this file input stream and releases any system resources associated with the stream.
Note: If this stream has an associated channel then the channel is closed as well.
Parameters: NA
Returns: NA
Throws:
IOException - if an I/O error occurs.
Approach
Java
import java.io.File;import java.io.FileInputStream;import java.io.IOException;public class FileInputStreamclose {public static void main(String[] args) throws IOException {String pathname = "D:\\hello.txt";File file = new File(pathname);FileInputStream fileInputStream =new FileInputStream(file);fileInputStream.close();System.out.println("Successfully closed");}}
Output:
Successfully closed
No comments:
Post a Comment