Package mil.nga.geopackage.io
Class GeoPackageIOUtils
- java.lang.Object
-
- mil.nga.geopackage.io.GeoPackageIOUtils
-
public class GeoPackageIOUtils extends Object
Input / Output utility methods- Author:
- osbornb
-
-
Field Summary
Fields Modifier and Type Field Description static intCOPY_BUFFER_SIZECopy stream buffer chunk size in bytes
-
Constructor Summary
Constructors Constructor Description GeoPackageIOUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FileaddFileExtension(File file, String extension)Add a the file extension to the filestatic StringaddFileExtension(String name, String extension)Add a the file extension to the namestatic voidcloseQuietly(Closeable closeable)Close the closeable quietlystatic voidcopyFile(File copyFrom, File copyTo)Copy a file to a file locationstatic voidcopyFile(File copyFrom, File copyTo, GeoPackageProgress progress)Copy a file to a file locationstatic voidcopyFile(File copyFrom, OutputStream copyTo)Copy a file to an output streamstatic voidcopyFile(File copyFrom, OutputStream copyTo, GeoPackageProgress progress)Copy a file to an output streamstatic voidcopyStream(InputStream copyFrom, File copyTo)Copy an input stream to a file locationstatic voidcopyStream(InputStream copyFrom, File copyTo, GeoPackageProgress progress)Copy an input stream to a file locationstatic voidcopyStream(InputStream copyFrom, OutputStream copyTo)Copy an input stream to an output streamstatic voidcopyStream(InputStream copyFrom, OutputStream copyTo, GeoPackageProgress progress)Copy an input stream to an output streamstatic byte[]fileBytes(File file)Get the file bytesstatic StringfileString(File file)Get the file stringstatic StringfileString(File file, String charsetName)Get the file stringstatic StringformatBytes(long bytes)Format the bytes into readable textstatic StringgetFileExtension(File file)Get the file extensionstatic StringgetFileExtension(String name)Get the file extensionstatic StringgetFileNameWithoutExtension(File file)Get the file name with the extension removedstatic StringgetFileNameWithoutExtension(String name)Get the file name with the extension removedstatic StringgetPathFileName(String path)Get the path file namestatic StringgetPathFileNameWithoutExtension(String path)Get the path file namestatic booleanhasFileExtension(File file)Check if the file has an extensionstatic booleanhasFileExtension(String name)Check if the name has an extensionstatic byte[]streamBytes(InputStream stream)Get the stream bytesstatic StringstreamString(InputStream stream)Get the stream string in UTF-8static StringstreamString(InputStream stream, String charsetName)Get the stream string
-
-
-
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- fileextension- 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- nameextension- 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 filecopyTo- 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 filecopyTo- to fileprogress- 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 filecopyTo- 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 filecopyTo- to streamprogress- 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 filecopyTo- 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 filecopyTo- to fileprogress- 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 filecharsetName- 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 streamcharsetName- 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 streamcopyTo- to stream- Throws:
IOException- upon failure
-
copyStream
public static void copyStream(InputStream copyFrom, OutputStream copyTo, GeoPackageProgress progress) throws IOException
Copy an input stream to an output stream- Parameters:
copyFrom- from streamcopyTo- to streamprogress- progress tracker- 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
-
-