fileinputstream read 28byte 5b 5d b 29 example

Solutions on MaxInterview for fileinputstream read 28byte 5b 5d b 29 example by the best coders in the world

showing results for - "fileinputstream read 28byte 5b 5d b 29 example"
Mohamed-Ali
01 May 2020
1package com.technicalkeeda;
2import java.io.FileInputStream;
3import java.io.IOException;
4public class App 5  public static void main(String[] args) {        
6    try {  
7      FileInputStream fileInputStream = new FileInputStream("C:\\technicalkeeda\\hello.txt");             
8      byte[] bytes = new byte[16];           
9      int i = fileInputStream.read(bytes);             
10      System.out.println("Total bytes read :- " + i);             
11      for (byte b: bytes) {                
12        char c = (char) b;                
13        System.out.print(c);            }             
14      fileInputStream.close();  
15    } 
16    catch (IOException e) {           
17      e.printStackTrace();       
1819  }
20}
21
22//  hello.txt contents is:
23//  Hello TechnicalKeeda
24
25//  output is: 
26//  Total bytes read :- 16
27// 
28//  Hello TechnicalK