Class ARCUtils

java.lang.Object
org.archive.io.arc.ARCUtils

public class ARCUtils extends Object
  • Constructor Details

    • ARCUtils

      public ARCUtils()
  • Method Details

    • parseArcFilename

      public static String parseArcFilename(String pathOrUri) throws URISyntaxException
      Parameters:
      pathOrUri - Path or URI to extract arc filename from.
      Returns:
      Extracted arc file name.
      Throws:
      URISyntaxException
    • isCompressed

      public static boolean isCompressed(File arcFile) throws IOException
      Parameters:
      arcFile - File to test.
      Returns:
      True if arcFile is compressed ARC.
      Throws:
      IOException
    • testCompressedARCFile

      public static boolean testCompressedARCFile(File arcFile) throws IOException
      Check file is compressed and in ARC GZIP format.
      Parameters:
      arcFile - File to test if its Internet Archive ARC file GZIP compressed.
      Returns:
      True if this is an Internet Archive GZIP'd ARC file (It begins w/ the Internet Archive GZIP header and has the COMPRESSED_ARC_FILE_EXTENSION suffix).
      Throws:
      IOException - If file does not exist or is not unreadable.
    • testCompressedARCFile

      public static boolean testCompressedARCFile(File arcFile, boolean skipSuffixCheck) throws IOException
      Check file is compressed and in ARC GZIP format.
      Parameters:
      arcFile - File to test if its Internet Archive ARC file GZIP compressed.
      skipSuffixCheck - Set to true if we're not to test on the '.arc.gz' suffix.
      Returns:
      True if this is an Internet Archive GZIP'd ARC file (It begins w/ the Internet Archive GZIP header).
      Throws:
      IOException - If file does not exist or is not unreadable.
    • testCompressedARCStream

      public static boolean testCompressedARCStream(InputStream is) throws IOException
      Tests passed stream is gzip stream by reading in the HEAD. Does not reposition the stream. That is left up to the caller.
      Parameters:
      is - An InputStream.
      Returns:
      True if compressed stream.
      Throws:
      IOException
    • testCompressedRepositionalStream

      public static boolean testCompressedRepositionalStream(RepositionableStream rs) throws IOException
      Tests passed stream is gzip stream by reading in the HEAD. Does reposition of stream when done.
      Parameters:
      rs - An InputStream that is Repositionable.
      Returns:
      True if compressed stream.
      Throws:
      IOException
    • testCompressedStream

      public static boolean testCompressedStream(InputStream is) throws IOException
      Tests passed stream is gzip stream by reading in the HEAD. Does reposition of stream when done.
      Parameters:
      is - An InputStream.
      Returns:
      True if compressed stream.
      Throws:
      IOException
    • testUncompressedARCFile

      public static boolean testUncompressedARCFile(File arcFile) throws IOException
      Check file is uncompressed ARC file.
      Parameters:
      arcFile - File to test if its Internet Archive ARC file uncompressed.
      Returns:
      True if this is an Internet Archive ARC file.
      Throws:
      IOException - If file does not exist or is not unreadable.