Here you can find the source of getBytes(String filePath)
Parameter | Description |
---|
Parameter | Description |
---|
public static byte[] getBytes(String filePath)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static byte[] getBytes(String filePath) { byte[] buffer = null; try {//from w w w. ja v a 2 s . c om File file = new File(filePath); FileInputStream fis = new FileInputStream(file); ByteArrayOutputStream bos = new ByteArrayOutputStream(1000); byte[] b = new byte[1000]; int n; while ((n = fis.read(b)) != -1) { bos.write(b, 0, n); } fis.close(); bos.close(); buffer = bos.toByteArray(); } catch (IOException e) { e.printStackTrace(); } return buffer; } }