Class FileUtils


  • public final class FileUtils
    extends Object
    File-based utilities.
    • Field Detail

      • CONFIG_FILE_LDP_TYPE

        public static final String CONFIG_FILE_LDP_TYPE
        The configuration key for controlling LDP type triples.
        See Also:
        Constant Field Values
      • CONFIG_FILE_DIGEST_ALGORITHM

        public static final String CONFIG_FILE_DIGEST_ALGORITHM
        The configuration key controlling the digest algorithm in use.
        See Also:
        Constant Field Values
      • LENGTH

        public static final int LENGTH
        The length of the CRC directory partition.
        See Also:
        Constant Field Values
    • Method Detail

      • getResourceDirectory

        public static File getResourceDirectory​(File baseDirectory,
                                                IRI identifier)
        Get a directory for a given resource identifier.
        Parameters:
        baseDirectory - the base directory
        identifier - a resource identifier
        Returns:
        a directory
      • parseQuad

        public static Stream<Quad> parseQuad​(String line)
        Parse a string into a stream of Quads.
        Parameters:
        line - the line of text
        Returns:
        the Quad
      • filterServerManagedQuads

        public static boolean filterServerManagedQuads​(Quad quad)
        Filter any server-managed triples from the resource stream.
        Parameters:
        quad - the quad
        Returns:
        true if the quad should be kept, false otherwise
      • uncheckedDeleteIfExists

        public static boolean uncheckedDeleteIfExists​(Path path)
        Try to delete a file if it exists or throw an unchecked exception.
        Parameters:
        path - the file path
        Returns:
        true if the file existed and was deleted; false otherwise
      • uncheckedList

        public static Stream<Path> uncheckedList​(Path path)
        Fetch a stream of files in the provided directory path.
        Parameters:
        path - the directory path
        Returns:
        a stream of filenames
      • writeMemento

        public static void writeMemento​(File resourceDir,
                                        Resource resource,
                                        Instant time)
        Write a Memento to a particular resource directory.
        Parameters:
        resourceDir - the resource directory
        resource - the resource
        time - the time for the memento
      • getBoundedStream

        public static InputStream getBoundedStream​(InputStream stream,
                                                   int from,
                                                   int to)
                                            throws IOException
        Get a bounded inputstream.
        Parameters:
        stream - the input stream
        from - the byte from which to start
        to - the byte to which to read
        Returns:
        the bounded inputstream
        Throws:
        IOException - if an error occurs when skipping forward
      • serializeQuad

        public static String serializeQuad​(Quad quad)
        Serialize an RDF Quad.
        Parameters:
        quad - the quad
        Returns:
        a serialization of the quad
      • getNquadsFile

        public static File getNquadsFile​(File dir,
                                         Instant time)
        Get the nquads file for a given moment in time.
        Parameters:
        dir - the directory
        time - the time
        Returns:
        the file