Here you can find the source of readFile(String path)
Parameter | Description |
---|---|
path | a parameter |
public static byte[] readFile(String path)
//package com.java2s; //License from project: Apache License import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class Main { /**// ww w. j a v a 2s . c om * Reads file and return the byte Array * * @param path * @return */ public static byte[] readFile(String path) { File file = new File(path); byte[] fileData = new byte[(int) file.length()]; DataInputStream dis; try { dis = new DataInputStream((new FileInputStream(file))); dis.readFully(fileData); dis.close(); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } return fileData; } }