writeBoolean(boolean): This method is available in the java.io.DataOutputStream class of Java.
Syntax:
void java.io.DataOutputStream.writeBoolean(boolean v) throws IOException
This method takes one argument. This method writes a boolean to the underlying output stream as a 1-byte value. The value true is written out as the value (byte)1; the value false is written out as the value (byte)0.
Note:
If no exception is thrown, the counter written is incremented by 1.
Parameters: One parameter is required for this method.
v: a boolean value to be written.
Throws:
IOException - if an I/O error occurs.
Approach
Java
import java.io.DataOutputStream;import java.io.FileOutputStream;import java.io.IOException;public class DataOutputStreamwriteBoolean {public static void main(String[] args) throws IOException {FileOutputStream file = new FileOutputStream("D:\\hello.txt");DataOutputStream data = new DataOutputStream(file);boolean v = true;data.writeBoolean(v);System.out.println("Successfully writes");data.close();}}
Output:
Successfully writes
No comments:
Post a Comment