Package libsidutils
Klasse IOUtils
java.lang.Object
libsidutils.IOUtils
This class provides general IO utility functions.
- Autor:
- Ken Händel
-
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 final StringcreateFilename(List<File> files) Reverse function ofgetFiles(String, File, FileFilter).
e.g.static final voiddeleteDirectory(File directory) Delete directory and contained files and sub-directories.static FileEventually extract file, if compressed (ZIP, GZIP, TAR, etc.), otherwise return same file.static final StringgetCollectionName(File collectionRoot, File file) Create a filename of the given path relative to the collection root dir.static final FileGet file for a given path.static final StringgetFilenameSuffix(String filename) Get suffix of a filename.static final 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 byte[]Read complete InputStream contents into byte arraystatic intreadNBytes(InputStream is, byte[] b, int off, int len) Read specific amount of InputStream contents into 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 filename where each path segment is delimited by a slash.
-
getFile
Get 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- 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 sub-directories.- 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 byte array- Parameter:
is- input- Gibt zurück:
- byte array
- Löst aus:
IOException- I/O error
-
readNBytes
Read specific amount of InputStream contents into byte array- Parameter:
is- inputb- byte arrayoff- offset in byte arraylen- number of bytes to read from input- Gibt zurück:
- byte array
- Löst aus:
IOException- I/O error
-
extract
Eventually extract file, if compressed (ZIP, GZIP, TAR, etc.), otherwise return same file.- Parameter:
baseDir- base directory to extract into a newly created sub-directoryinputFile- input to extract- Gibt zurück:
- extracted file or same file (if it was uncompressed)
- Löst aus:
IOException- I/O error
-