java.lang.Object
ushiosan.jvm_utilities.internal.io.IOImpl
ushiosan.jvm_utilities.lang.io.IO
-
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 extensiongetFilename(@NotNull File file) getFilename(@NotNull Path location) getFilename(@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
-
getFilename
-
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
-
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
-