In this section, we are going to show the array of bytes from the specified file. For this, a file 'Hello.txt' is passed into the constructor of class File.
Get Byte Array from File
In this section, we are going to show the array of bytes from the specified file. For this, a file 'Hello.txt' is passed into the constructor of class File.
fileInputStream.read(b)- This method reads the the file in bytes.
int b[i]- This will show the character in bytes.
char b[i]- This will show the character.
Here is the video tutorial of "How to read a file in byte array in Java?":
Here is the code of GetByteArrayFromfile.java
import java.io.*;
|
Output will be displayed as: