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 Path path) Returns all existing extensions in a file.getBaseName(@NotNull Path path) Get the file base name, without any extension.getExtension(@NotNull Path path) Returns the file extension.getExtensionUnsafe(@NotNull Path path) Returns the file extensionstatic @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
-
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
-
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
-
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
-
getExtensionUnsafe
Returns the file extension- Parameters:
path- the path to analyze- Returns:
- returns the file 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
-