Package libsidutils
Klasse IOUtils
java.lang.Object
libsidutils.IOUtils
This class provides general IO utility functions.
- Autor:
- Ken Händel
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic interfacestatic interface -
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprivate static final intprivate static final intprivate static final PatternLinux, OSX, and ZIP entries use slash, Windows uses backslash. -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungaddUpperCase(List<String> fileExtensions) Add upper case file extensions to the file extensions list.static StringconvertStreamToString(InputStream is, Charset charset) Convert InputStream to String using charset.static StringconvertStreamToString(InputStream is, Charset charset, Map<String, String> replacements) Convert InputStream to String using charset and replace strings on demand.static voidcopy(InputStream is, OutputStream os) Fast file channel-based copy.private static StringcreateFilename(List<File> files) Reverse function ofgetFiles(String, File, FileFilter).
e.g.static voiddeleteDirectory(File directory) Delete directory and contained files and subdirectories.static FileEventually extract a file, if compressed (ZIP, GZIP, TAR, etc.), otherwise return the same file.static StringgetCollectionName(File collectionRoot, File file) Create a filename of the given path relative to the collection root dir.static FileGet a file for a given path.static StringgetFilenameSuffix(String filename) Get suffix of a filename.static StringgetFilenameWithoutSuffix(String filename) Strip suffix of a filename.getFiles(String path, File rootFile, FileFilter fileFilter) Get the file list of the given file path.static StringgetPhysicalSize(long size) Get physical size in b, Kb, Mb, Gb, or Tb.static voidioWrap(BooleanSupplier action) static voidioWrap(IOUtils.IntSupplierThatThrows action) static voidstatic byte[]Read complete InputStream contents into a byte arraystatic intreadNBytes(InputStream is, byte[] b, int off, int len) Read a specific number of InputStream contents into a byte array
-
Felddetails
-
SEPARATOR
Linux, OSX, and ZIP entries use slash, Windows uses backslash. -
COPY_BUFFER_CHUNK_SIZE
private static final int COPY_BUFFER_CHUNK_SIZE- Siehe auch:
-
BUFFER_LENGTH
private static final int BUFFER_LENGTH- Siehe auch:
-
-
Konstruktordetails
-
IOUtils
public IOUtils()
-
-
Methodendetails
-
getCollectionName
Create a filename of the given path relative to the collection root dir.
e.g. "<root>/MUSICIANS/D/Daglish_Ben/Bombo.sid" -> "/MUSICIANS/D/Daglish_Ben/Bombo.sid"- Parameter:
collectionRoot- root file of the pathfile- file to get the relative path for- Gibt zurück:
- relative path to the collection root file (empty string, if the path is not relative to the collection root file)
-
createFilename
Reverse function ofgetFiles(String, File, FileFilter).
e.g. [File(D), File(Daglish_Ben), File(Bombo.sid)] -> "/MUSICIANS/D/Daglish_Ben/Bombo.sid"- Parameter:
files- file list to create a filename for- Gibt zurück:
- filename where a slash delimits each path segment.
-
getFile
Get a file for a given path. The path can be relative to HVSC or CGSC or even absolute.
e.g. "<root>/MUSICIANS/D/Daglish_Ben/Bombo.sid" -> File(/MUSICIANS/D/Daglish_Ben/Bombo.sid)- Parameter:
path- the path to get a file for, possible root directory can be either hvscRoot or cgscRoot or none, if absolutehvscRoot- root of HVSCcgscRoot- root of CGSC- Gibt zurück:
- file of the path
-
getFiles
Get the file list of the given file path. Each entry corresponds to a path segment. It is sorted from parent to child.
e.g. "<root>/MUSICIANS/D/Daglish_Ben/Bombo.sid" -> [File(MUSICIANS), File(D), File(Daglish_Ben), File(Bombo.sid)]- Parameter:
path- file path to get the file list for. Each path segment is delimited by slash or backslash.rootFile- Root file to start. The first path segment must match a direct child of rootPath and so on.fileFilter- Files contained in the file filter are visible as child files (null means filter disabled)- Gibt zurück:
- a file list sorted from the parent file to the child file (empty list, if the path is wrong or incomplete)
-
deleteDirectory
Delete directory and contained files and subdirectories.- Parameter:
directory- directory to delete- Löst aus:
IOException- error during delete
-
getFilenameWithoutSuffix
Strip suffix of a filename.- Parameter:
filename- filename to get the suffix for- Gibt zurück:
- filename without suffix (e.g. "Bombo.sid" -> "Bombo")
-
getFilenameSuffix
Get suffix of a filename.- Parameter:
filename- filename to get the suffix for- Gibt zurück:
- suffix of a filename (e.g. "Bombo.sid" -> ".sid")
-
addUpperCase
Add upper case file extensions to the file extensions list.- Parameter:
fileExtensions- file extensions to add to- Gibt zurück:
- file extensions with added upper case file extensions
-
getPhysicalSize
Get physical size in b, Kb, Mb, Gb, or Tb.- Parameter:
size- size to calculate physical size for- Gibt zurück:
- physical size
-
copy
Fast file channel-based copy.- Parameter:
is- inputos- output- Löst aus:
IOException- I/O error
-
convertStreamToString
Convert InputStream to String using charset.- Parameter:
is- inputcharset- charset- Gibt zurück:
- read string
-
convertStreamToString
public static String convertStreamToString(InputStream is, Charset charset, Map<String, String> replacements) Convert InputStream to String using charset and replace strings on demand.- Parameter:
is- inputcharset- charsetreplacements- replacement strings- Gibt zurück:
- read string
-
readAllBytes
Read complete InputStream contents into a byte array- Parameter:
is- input- Gibt zurück:
- byte array
- Löst aus:
IOException- I/O error
-
readNBytes
Read a specific number of InputStream contents into a byte array- Parameter:
is- inputb- byte arrayoff- offset in a byte arraylen- number of bytes to read from input- Gibt zurück:
- byte array
- Löst aus:
IOException- I/O error
-
extract
Eventually extract a file, if compressed (ZIP, GZIP, TAR, etc.), otherwise return the same file.- Parameter:
baseDir- base directory to extract into a newly created subdirectoryinputFile- input to extract- Gibt zurück:
- extracted file or same file (if it was uncompressed)
- Löst aus:
IOException- I/O error
-
ioWrap
-
ioWrap2
-
ioWrap
- Löst aus:
IOException
-