Class GeoPackageIOUtils


  • public class GeoPackageIOUtils
    extends Object
    Input / Output utility methods
    Author:
    osbornb
    • Field Detail

      • COPY_BUFFER_SIZE

        public static int COPY_BUFFER_SIZE
        Copy stream buffer chunk size in bytes
        Since:
        3.3.0
    • Constructor Detail

      • GeoPackageIOUtils

        public GeoPackageIOUtils()
    • Method Detail

      • getFileExtension

        public static String getFileExtension​(File file)
        Get the file extension
        Parameters:
        file - file
        Returns:
        extension
      • getFileExtension

        public static String getFileExtension​(String name)
        Get the file extension
        Parameters:
        name - name
        Returns:
        extension
        Since:
        3.5.0
      • hasFileExtension

        public static boolean hasFileExtension​(File file)
        Check if the file has an extension
        Parameters:
        file - file
        Returns:
        true if has extension
        Since:
        3.0.2
      • hasFileExtension

        public static boolean hasFileExtension​(String name)
        Check if the name has an extension
        Parameters:
        name - name
        Returns:
        true if has extension
        Since:
        3.5.0
      • addFileExtension

        public static File addFileExtension​(File file,
                                            String extension)
        Add a the file extension to the file
        Parameters:
        file - file
        extension - file extension
        Returns:
        new file with extension
        Since:
        3.0.2
      • addFileExtension

        public static String addFileExtension​(String name,
                                              String extension)
        Add a the file extension to the name
        Parameters:
        name - name
        extension - file extension
        Returns:
        new name with extension
        Since:
        3.5.0
      • getFileNameWithoutExtension

        public static String getFileNameWithoutExtension​(File file)
        Get the file name with the extension removed
        Parameters:
        file - file
        Returns:
        file name
      • getFileNameWithoutExtension

        public static String getFileNameWithoutExtension​(String name)
        Get the file name with the extension removed
        Parameters:
        name - name
        Returns:
        file name
        Since:
        3.5.0
      • getPathFileName

        public static String getPathFileName​(String path)
        Get the path file name
        Parameters:
        path - file path
        Returns:
        file name
        Since:
        6.2.0
      • getPathFileNameWithoutExtension

        public static String getPathFileNameWithoutExtension​(String path)
        Get the path file name
        Parameters:
        path - file path
        Returns:
        file name
        Since:
        6.2.0
      • copyFile

        public static void copyFile​(File copyFrom,
                                    File copyTo)
                             throws IOException
        Copy a file to a file location
        Parameters:
        copyFrom - from file
        copyTo - to file
        Throws:
        IOException - upon failure
      • copyFile

        public static void copyFile​(File copyFrom,
                                    File copyTo,
                                    GeoPackageProgress progress)
                             throws IOException
        Copy a file to a file location
        Parameters:
        copyFrom - from file
        copyTo - to file
        progress - progress tracker
        Throws:
        IOException - upon failure
        Since:
        5.0.0
      • copyFile

        public static void copyFile​(File copyFrom,
                                    OutputStream copyTo)
                             throws IOException
        Copy a file to an output stream
        Parameters:
        copyFrom - from file
        copyTo - to stream
        Throws:
        IOException - upon failure
        Since:
        5.0.0
      • copyFile

        public static void copyFile​(File copyFrom,
                                    OutputStream copyTo,
                                    GeoPackageProgress progress)
                             throws IOException
        Copy a file to an output stream
        Parameters:
        copyFrom - from file
        copyTo - to stream
        progress - progress tracker
        Throws:
        IOException - upon failure
        Since:
        5.0.0
      • copyStream

        public static void copyStream​(InputStream copyFrom,
                                      File copyTo)
                               throws IOException
        Copy an input stream to a file location
        Parameters:
        copyFrom - from file
        copyTo - to file
        Throws:
        IOException - upon failure
      • copyStream

        public static void copyStream​(InputStream copyFrom,
                                      File copyTo,
                                      GeoPackageProgress progress)
                               throws IOException
        Copy an input stream to a file location
        Parameters:
        copyFrom - from file
        copyTo - to file
        progress - progress tracker
        Throws:
        IOException - upon failure
      • fileBytes

        public static byte[] fileBytes​(File file)
                                throws IOException
        Get the file bytes
        Parameters:
        file - input file
        Returns:
        file bytes
        Throws:
        IOException - upon failure
      • fileString

        public static String fileString​(File file)
                                 throws IOException
        Get the file string
        Parameters:
        file - input file
        Returns:
        file string
        Throws:
        IOException - upon failure
        Since:
        6.6.0
      • fileString

        public static String fileString​(File file,
                                        String charsetName)
                                 throws IOException
        Get the file string
        Parameters:
        file - input file
        charsetName - character set name
        Returns:
        file string
        Throws:
        IOException - upon failure
        Since:
        6.6.0
      • streamBytes

        public static byte[] streamBytes​(InputStream stream)
                                  throws IOException
        Get the stream bytes
        Parameters:
        stream - input stream
        Returns:
        stream bytes
        Throws:
        IOException - upon failure
      • streamString

        public static String streamString​(InputStream stream)
                                   throws IOException
        Get the stream string in UTF-8
        Parameters:
        stream - input stream
        Returns:
        stream string
        Throws:
        IOException - upon failure
        Since:
        3.3.0
      • streamString

        public static String streamString​(InputStream stream,
                                          String charsetName)
                                   throws IOException
        Get the stream string
        Parameters:
        stream - input stream
        charsetName - character set name
        Returns:
        stream string
        Throws:
        IOException - upon failure
        Since:
        3.3.0
      • copyStream

        public static void copyStream​(InputStream copyFrom,
                                      OutputStream copyTo)
                               throws IOException
        Copy an input stream to an output stream
        Parameters:
        copyFrom - from stream
        copyTo - to stream
        Throws:
        IOException - upon failure
      • formatBytes

        public static String formatBytes​(long bytes)
        Format the bytes into readable text
        Parameters:
        bytes - bytes
        Returns:
        bytes text
      • closeQuietly

        public static void closeQuietly​(Closeable closeable)
        Close the closeable quietly
        Parameters:
        closeable - closeable (stream, etc)
        Since:
        2.0.2