writeByte(int): This method is available in the java.io.DataOutputStream class of Java.
Syntax:
void java.io.DataOutputStream.writeByte(int v) throws IOException
This method takes one argument. This method writes out a byte to the underlying output stream as a 1-byte value.
Note:
If no exception is thrown, the counter written is incremented by 1.
Parameters: One parameter is required for this method.
v: a byte 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 DataOutputStreamwriteByte {public static void main(String[] args) throws IOException {FileOutputStream file =new FileOutputStream("D:\\hello.txt");DataOutputStream data = new DataOutputStream(file);int v = 65;data.writeByte(v);System.out.println("Successfully writes");data.close();}}
Output:
Successfully writes
hello.txt
A
No comments:
Post a Comment