I think its unnecessary to allocate a ByteArrayOutputStream here. Instead you can write the method as:

  FileInputStream in = new FileInputStream(path);
  try {
    byte[] buf = new byte[limit];
    int cnt = 0;
    for (;;) {
      int n = in.read(buf, cnt, buf.length - cnt);
      if (n <= 0)
        break;
      cnt += n;
    }
    if (cnt == buf.length)
      return buf;
    byte[] res = new byte[cnt];
    System.arraycopy(buf, 0, res, 0, cnt);
    return res;
  } finally {
    try {
      in.close();
    } catch (IOException ignored) {
    }
  }