Exemplo n.º 1
0
  /**
   * Get binary data of a source file.
   *
   * @param path The canonical path of source file.
   * @return Source file data.
   */
  public byte[] read(String path) {
    if (!binaryCache.containsKey(path)) {
      try {
        BufferedInputStream bf = new BufferedInputStream(new FileInputStream(new File(path)));
        try {
          byte[] data = new byte[bf.available()];
          bf.read(data);
          detectBOM(data, path);
          binaryCache.put(path, data);
        } finally {
          bf.close();
        }
      } catch (IOException e) {
        App.exit(e);
      }
    }

    return binaryCache.get(path);
  }