Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 980 Bytes

Java - Files and Input Output.md

File metadata and controls

20 lines (16 loc) · 980 Bytes

How to convert File to byte[]

File file = new File("/temp/abc.txt");
  //init array with file length
  byte[] bytesArray = new byte[(int) file.length()]; 

  FileInputStream fis = new FileInputStream(file);
  fis.read(bytesArray); //read file into bytes[]
  fis.close();
			
  return bytesArray;