fileinputstream read() with two or more bytes code example
Example: fileinputstream read(byte[] b) example
package com.technicalkeeda;
import java.io.FileInputStream;
import java.io.IOException;
public class App {
public static void main(String[] args) {
try {
FileInputStream fileInputStream = new FileInputStream("C:\\technicalkeeda\\hello.txt");
byte[] bytes = new byte[16];
int i = fileInputStream.read(bytes);
System.out.println("Total bytes read :- " + i);
for (byte b: bytes) {
char c = (char) b;
System.out.print(c); }
fileInputStream.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}