java.lang.Object
ushiosan.jvm_utilities.internal.io.IOImpl
ushiosan.jvm_utilities.lang.io.IO
Class containing functionality for input and output elements.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]Empty extensions arraystatic final charCharacter used to identify all file extensionsFields inherited from class ushiosan.jvm_utilities.internal.io.IOImpl
FILESYSTEM_ROOT -
Method Summary
Modifier and TypeMethodDescriptiongetAllExtensions(@NotNull File file) Returns all existing extensions in a file.getAllExtensions(@NotNull Path path) Returns all existing extensions in a file.getAllExtensions(@NotNull ZipEntry entry) Returns all existing extensions in a zip entry object.getBaseName(@NotNull File file) Get the file base name, without any extension.getBaseName(@NotNull Path path) Get the file base name, without any extension.getBaseName(@NotNull ZipEntry entry) Get the file base name, without any extension.getExtension(@NotNull File file) Returns the file extension.getExtension(@NotNull Path path) Returns the file extension.getExtension(@NotNull ZipEntry entry) Returns the zip entry extension.getExtensionUnsafe(@NotNull File file) Returns the file extensiongetExtensionUnsafe(@NotNull Path path) Returns the file extensiongetExtensionUnsafe(@NotNull ZipEntry entry) Returns the zip entry extensionstatic byte[]getFileHash(@NotNull File file) Returns the hash of a file depending on the given configuration.static byte[]getFileHash(@NotNull File file, @NotNull String algorithm) Returns the hash of a file depending on the given configuration.static byte[]getFileHash(@NotNull Path path) Returns the hash of a file depending on the given configuration.static byte[]getFileHash(@NotNull Path path, @NotNull String algorithm) Returns the hash of a file depending on the given configuration.static byte[]getFileHash(@NotNull ZipFile zipFile, @NotNull ZipEntry entry) Returns the hash of a file depending on the given configuration.static byte[]Returns the hash of a file depending on the given configuration.getFileHashStr(@NotNull File file) Returns the hash of a file depending on the given configuration.getFileHashStr(@NotNull File file, @NotNull String algorithm) Returns the hash of a file depending on the given configuration.getFileHashStr(@NotNull Path path) Returns the hash of a file depending on the given configuration.getFileHashStr(@NotNull Path path, @NotNull String algorithm) Returns the hash of a file depending on the given configuration.getFileHashStr(@NotNull ZipFile zipFile, @NotNull ZipEntry entry) Returns the hash of a file depending on the given configuration.Returns the hash of a file depending on the given configuration.getFilename(@NotNull File file) Returns the file namegetFilename(@NotNull Path location) Returns the location namegetFilename(@NotNull ZipEntry entry) Returns the entry name of a zip filestatic @NotNull FileSystemgetFilesystem(@NotNull URI uri) Returns a valid file system depending on the scheme of the given urlstatic @NotNull FileSystemgetFilesystem(@NotNull URL url) Returns a valid file system depending on the scheme of the given urlDepending on the operating system, it returns the path of the current user.Returns the path of an url in the file system (if the scheme is supported).Returns the path of an url in the file system (if the scheme is supported).resolveUserPath(String @NotNull ... location) Returns a specific path within the user's folder.Generates a stream where it recursively iterates through all the directories within the given destination.Generates an array where it recursively iterates through all the directories within the given destination.Methods inherited from class ushiosan.jvm_utilities.internal.io.IOImpl
getValidFilesystem, getValidFilesystem, getValidPath, getValidPath
-
Field Details
-
EMPTY_EXTENSIONS
Empty extensions array -
EXTENSION_IDENTIFIER
public static final char EXTENSION_IDENTIFIERCharacter used to identify all file extensions- See Also:
-
-
Method Details
-
getFilename
Returns the location name- Parameters:
location- the location to inspect- Returns:
- the name of the entry
-
getFilename
Returns the file name- Parameters:
file- the file object- Returns:
- the name of the entry
-
getFilename
Returns the entry name of a zip file- Parameters:
entry- the entry file object- Returns:
- the name of the entry
-
getBaseName
Get the file base name, without any extension.Example:
"build.gradle.kts" -> build "example.file.java" -> example- Parameters:
path- the path to analyze- Returns:
- the file base name
-
getBaseName
Get the file base name, without any extension.Example:
"build.gradle.kts" -> build "example.file.java" -> example- Parameters:
file- the file to analyze- Returns:
- the file base name
-
getBaseName
Get the file base name, without any extension.Example:
"build.gradle.kts" -> build "example.file.java" -> example- Parameters:
entry- the zip entry to analyze- Returns:
- the entry base name
-
getAllExtensions
@Contract("_ -> new") public static String @NotNull [] getAllExtensions(@NotNull @NotNull Path path) Returns all existing extensions in a file.Example:
"build.gradle.kts" -> [gradle, kts] "example.file.java" -> [file, java]- Parameters:
path- the path to analyze- Returns:
- all file extensions
-
getAllExtensions
@Contract("_ -> new") public static String @NotNull [] getAllExtensions(@NotNull @NotNull File file) Returns all existing extensions in a file.Example:
"build.gradle.kts" -> [gradle, kts] "example.file.java" -> [file, java]- Parameters:
file- the file to analyze- Returns:
- all file extensions
-
getAllExtensions
@Contract("_ -> new") public static String @NotNull [] getAllExtensions(@NotNull @NotNull ZipEntry entry) Returns all existing extensions in a zip entry object.Example:
"build.gradle.kts" -> [gradle, kts] "example.file.java" -> [file, java]- Parameters:
entry- the entry to analyze- Returns:
- all file extensions
-
getExtension
Returns the file extension.Example:
"build.gradle.kts" -> Optional["kts"] "example.file.java" -> Optional["java"] "binary_file" -> Optional[empty]- Parameters:
path- the path to analyze- Returns:
- returns the file extension or
Optional.empty()if the extension not exists
-
getExtension
Returns the file extension.Example:
"build.gradle.kts" -> Optional["kts"] "example.file.java" -> Optional["java"] "binary_file" -> Optional[empty]- Parameters:
file- the file to analyze- Returns:
- returns the file extension or
Optional.empty()if the extension not exists
-
getExtension
Returns the zip entry extension.Example:
"build.gradle.kts" -> Optional["kts"] "example.file.java" -> Optional["java"] "binary_file" -> Optional[empty]- Parameters:
entry- the zip entry to analyze- Returns:
- returns the file extension or
Optional.empty()if the extension not exists
-
getExtensionUnsafe
Returns the file extension- Parameters:
path- the path to analyze- Returns:
- returns the file extension or empty string if the extension not exists
-
getExtensionUnsafe
Returns the file extension- Parameters:
file- the path to analyze- Returns:
- returns the file extension or empty string if the extension not exists
-
getExtensionUnsafe
Returns the zip entry extension- Parameters:
entry- the path to analyze- Returns:
- returns the zip entry extension or empty string if the extension not exists
-
getFileHash
public static byte[] getFileHash(@NotNull @NotNull Path path, @NotNull @NotNull String algorithm) throws IOException Returns the hash of a file depending on the given configuration. This method returns the hash bytes.- Parameters:
path- the file to inspectalgorithm- the hash algorithm- Returns:
- the hash result
- Throws:
IOException- error to open file
-
getFileHash
Returns the hash of a file depending on the given configuration. This method returns the hash bytes.- Parameters:
path- the file to inspect- Returns:
- the hash result
- Throws:
IOException- error to open file
-
getFileHash
public static byte[] getFileHash(@NotNull @NotNull File file, @NotNull @NotNull String algorithm) throws IOException Returns the hash of a file depending on the given configuration. This method returns the hash bytes.- Parameters:
file- the file to inspectalgorithm- the hash algorithm- Returns:
- the hash result
- Throws:
IOException- error to open file
-
getFileHash
Returns the hash of a file depending on the given configuration. This method returns the hash bytes.- Parameters:
file- the file to inspect- Returns:
- the hash result
- Throws:
IOException- error to open file
-
getFileHash
public static byte[] getFileHash(@NotNull @NotNull ZipFile zipFile, @NotNull @NotNull ZipEntry entry, @NotNull @NotNull String algorithm) throws IOException Returns the hash of a file depending on the given configuration. This method returns the hash bytes.- Parameters:
zipFile- the root zip fileentry- the file to inspectalgorithm- the hash algorithm- Returns:
- the hash result
- Throws:
IOException- error to open file
-
getFileHash
public static byte[] getFileHash(@NotNull @NotNull ZipFile zipFile, @NotNull @NotNull ZipEntry entry) throws IOException Returns the hash of a file depending on the given configuration. This method returns the hash bytes.- Parameters:
zipFile- the root zip fileentry- the file to inspect- Returns:
- the hash result
- Throws:
IOException- error to open file
-
getFileHashStr
@NotNull public static @NotNull String getFileHashStr(@NotNull @NotNull Path path, @NotNull @NotNull String algorithm) throws IOException Returns the hash of a file depending on the given configuration. This method returns the hash as hexadecimal string.- Parameters:
path- the file to inspectalgorithm- the hash algorithm- Returns:
- the hash result
- Throws:
IOException- error to open file
-
getFileHashStr
@NotNull public static @NotNull String getFileHashStr(@NotNull @NotNull Path path) throws IOException Returns the hash of a file depending on the given configuration. This method returns the hash as hexadecimal string.- Parameters:
path- the file to inspect- Returns:
- the hash result
- Throws:
IOException- error to open file
-
getFileHashStr
@NotNull public static @NotNull String getFileHashStr(@NotNull @NotNull File file, @NotNull @NotNull String algorithm) throws IOException Returns the hash of a file depending on the given configuration. This method returns the hash as hexadecimal string.- Parameters:
file- the file to inspectalgorithm- the hash algorithm- Returns:
- the hash result
- Throws:
IOException- error to open file
-
getFileHashStr
@NotNull public static @NotNull String getFileHashStr(@NotNull @NotNull File file) throws IOException Returns the hash of a file depending on the given configuration. This method returns the hash as hexadecimal string.- Parameters:
file- the file to inspect- Returns:
- the hash result
- Throws:
IOException- error to open file
-
getFileHashStr
@NotNull public static @NotNull String getFileHashStr(@NotNull @NotNull ZipFile zipFile, @NotNull @NotNull ZipEntry entry, @NotNull @NotNull String algorithm) throws IOException Returns the hash of a file depending on the given configuration. This method returns the hash as hexadecimal string.- Parameters:
zipFile- the root zip fileentry- the file to inspectalgorithm- the hash algorithm- Returns:
- the hash result
- Throws:
IOException- error to open file
-
getFileHashStr
@NotNull public static @NotNull String getFileHashStr(@NotNull @NotNull ZipFile zipFile, @NotNull @NotNull ZipEntry entry) throws IOException Returns the hash of a file depending on the given configuration. This method returns the hash as hexadecimal string.- Parameters:
zipFile- the root zip fileentry- the file to inspect- Returns:
- the hash result
- Throws:
IOException- error to open file
-
resolveUserPath
Returns a specific path within the user's folder.- Parameters:
location- the path to resolve- Returns:
- the resolved user relative path
-
getUserPath
Depending on the operating system, it returns the path of the current user.- Returns:
- the path to the current user's folder.
-
walkDir
@SafeVarargs @NotNull public static @NotNull Stream<Path> walkDir(@NotNull @NotNull Path location, boolean recursive, Predicate<Path> @NotNull ... predicates) throws IOException Generates a stream where it recursively iterates through all the directories within the given destination.- Parameters:
location- base directoryrecursive- determines if the stream is required to be recursive or just the first directorypredicates- filters applied to the stream- Returns:
- a stream with all the given settings
- Throws:
IOException- error if directory not exists or location is not a valid directory- See Also:
-
walkDirArr
@SafeVarargs public static Path @NotNull [] walkDirArr(@NotNull @NotNull Path location, boolean recursive, Predicate<Path> @NotNull ... predicates) throws IOException Generates an array where it recursively iterates through all the directories within the given destination.- Parameters:
location- base directoryrecursive- determines if the stream is required to be recursive or just the first directorypredicates- filters applied to the stream- Returns:
- an array with all files with the given data configuration
- Throws:
IOException- error if directory not exists or location is not a valid directory- See Also:
-
getFilesystem
@NotNull public static @NotNull FileSystem getFilesystem(@NotNull @NotNull URL url) throws IOException Returns a valid file system depending on the scheme of the given url- Parameters:
url- the url to inspect- Returns:
- valid filesystem
- Throws:
IOException- error if url schema is not supported
-
getFilesystem
@NotNull public static @NotNull FileSystem getFilesystem(@NotNull @NotNull URI uri) throws IOException Returns a valid file system depending on the scheme of the given url- Parameters:
uri- the url to inspect- Returns:
- valid filesystem
- Throws:
IOException- error if url schema is not supported
-
pathOf
Returns the path of an url in the file system (if the scheme is supported).If the schema is a jar file, the virtual representation of the file as a directory will be returned.
- Parameters:
url- the url to inspect- Returns:
- a valid file path
- Throws:
IOException- error if given url is not supported
-
pathOf
Returns the path of an url in the file system (if the scheme is supported).If the schema is a jar file, the virtual representation of the file as a directory will be returned.
- Parameters:
uri- the url to inspect- Returns:
- a valid file path
- Throws:
IOException- error if given url is not supported
-