References: Writer Class
Approach:
Writer class is used to write character stream, by which byte array can be passed as an argument. By this way, byte array can be converted into Writer class. To get the byte array from String, getBytes() method is used.
Below is the implementation of the above approach:
Program:
Output:
Speed of light: 3.0e8