Java Code Examples for org.apache.commons.compress.archivers.tar.TarArchiveInputStream#matches()

The following examples show how to use org.apache.commons.compress.archivers.tar.TarArchiveInputStream#matches() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TarUtils.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
public static boolean isTarFile(File file) throws IOException {
  if (file.isDirectory()) {
    return false;
  }
  // http://en.wikipedia.org/wiki/Tar_(computing)#File_header
  final byte[] header = new byte[512];
  try (FileInputStream fIn = new FileInputStream(file)) {
    if (fIn.read(header) != header.length) {
      return false;
    }
  }
  return TarArchiveInputStream.matches(header, header.length);
}
 
Example 2
Source File: TarFileSystemFactory.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public boolean probeStartBytes(FSRL containerFSRL, byte[] startBytes) {
	return TarArchiveInputStream.matches(startBytes, startBytes.length);
}