close(): This method is available in the java.io.DataOutputStream class of Java.
Syntax:
void java.io.FilterOutputStream.close() throws IOException
This method closes this output stream and releases any system resources associated with the stream.
Parameters: NA
Returns: NA
Throws: IOException - if an I/O error occurs.
Approach
Java
import java.io.DataOutputStream;import java.io.FileOutputStream;import java.io.IOException;public class DataOutputStreamclose {public static void main(String[] args) throws IOException {FileOutputStream file = newFileOutputStream("D:\\hello.txt");DataOutputStream data = new DataOutputStream(file);data.close();System.out.println("successfully closed");}}
Output:
successfully closed
No comments:
Post a Comment