
read a file byte by byte

import java.io.File; import java.io.FileInputStream;
public class ReadFileByteArray {
public static void main(String[] args) {
File file = new File("D://Try.txt");
try {
FileInputStream fin = new FileInputStream(file);
byte fileContent[] = new byte[(int) file.length()];
fin.read(fileContent);
String strFileContent = new String(fileContent);
System.out.println("File content : ");
System.out.println(strFileContent);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Hello Friend,
Please go through the following link:
http://www.roseindia.net/tutorial/java/core/files/fileToByteArray.html
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.