Here you can find the source of getBytes(String filePath, long startPos, long endPos)
public static byte[] getBytes(String filePath, long startPos, long endPos)
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class Main { private static final int DEFAULT_BUFF_SIZE = 1024; private static final int UNIT_LEN = 8; public static byte[] getBytes(String filePath, long startPos, long endPos) { byte[] buffer = null; try {/*from ww w. j av a 2 s .c o m*/ File file = new File(filePath); FileInputStream fis = new FileInputStream(file); ByteArrayOutputStream bos = new ByteArrayOutputStream(DEFAULT_BUFF_SIZE * UNIT_LEN); byte[] b = new byte[DEFAULT_BUFF_SIZE * UNIT_LEN]; int n; while ((n = fis.read(b)) != -1) { bos.write(b, 0, n); } fis.close(); bos.close(); buffer = bos.toByteArray(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return buffer; } }