- java.lang.Object
-
- life.expert.common.io.FileWrappers
-
public final class FileWrappers extends java.lang.ObjectThe type File helper.
-
-
Constructor Summary
Constructors Constructor Description FileWrappers()
-
Method Summary
Modifier and Type Method Description static java.io.FilecreateOrRetrieveFile(@Nullable java.lang.String file, @Nullable java.nio.file.Path directory)Create or retrieve file file.static java.util.Optional<java.net.URL>fileToUrl(@NotNull java.io.File file)for using inside streamApi hide exception and return optionalstatic <E> java.util.Optional<E>ioOptional(@Nullable SupplierIO<E> operation)Io optional optional.static voidioWrapper(@NotNull RunnableIO operation)Io wrapper.static voidioWrapper(@NotNull RunnableIO operation, @NotNull java.lang.String errorMessage)Io wrapper.static voidioWrapper(@NotNull RunnableIO operation, @NotNull java.util.function.Supplier<java.lang.String> errorMessage)Io wrapper.static <E> EioWrapper(@NotNull SupplierIO<E> operation)Io wrapper e.static <E> EioWrapper(@NotNull SupplierIO<E> operation, @NotNull java.lang.String errorMessage)Io wrapper e.static <E> EioWrapper(@NotNull SupplierIO<E> operation, @NotNull java.util.function.Supplier<java.lang.String> errorMessage)Io wrapper e.static <E> voidioWrapper(E input, @NotNull ConsumerIO<E> operation)Io wrapper.static <E> voidioWrapper(E input, @NotNull ConsumerIO<E> operation, @NotNull java.lang.String errorMessage)Io wrapper.static <E> voidioWrapper(E input, @NotNull ConsumerIO<E> operation, @NotNull java.util.function.Supplier<java.lang.String> errorMessage)Io wrapper.static RunnableIOwriterWrapper(@NotNull java.io.File file, @NotNull java.util.function.Supplier<java.lang.String> textToWrite)Writer wrapper runnable io.
-
-
-
Method Detail
-
fileToUrl
public static java.util.Optional<java.net.URL> fileToUrl(@NotNull @NotNull java.io.File file)for using inside streamApi hide exception and return optional- Parameters:
file- the file- Returns:
- the optional
-
createOrRetrieveFile
public static java.io.File createOrRetrieveFile(@Nullable @Nullable java.lang.String file, @Nullable @Nullable java.nio.file.Path directory)Create or retrieve file file.- Parameters:
file- the filedirectory- the directory- Returns:
- the file
-
ioWrapper
public static void ioWrapper(@NotNull @NotNull RunnableIO operation)Io wrapper.- Parameters:
operation- the operation
-
ioWrapper
public static void ioWrapper(@NotNull @NotNull RunnableIO operation, @NotNull @NotNull java.lang.String errorMessage)Io wrapper.- Parameters:
operation- the operationerrorMessage- the error message
-
ioWrapper
public static void ioWrapper(@NotNull @NotNull RunnableIO operation, @NotNull @NotNull java.util.function.Supplier<java.lang.String> errorMessage)Io wrapper.- Parameters:
operation- the operationerrorMessage- the error message
-
ioWrapper
public static <E> E ioWrapper(@NotNull @NotNull SupplierIO<E> operation)Io wrapper e.- Type Parameters:
E- the type parameter- Parameters:
operation- the operation- Returns:
- the e
-
ioWrapper
public static <E> E ioWrapper(@NotNull @NotNull SupplierIO<E> operation, @NotNull @NotNull java.lang.String errorMessage)Io wrapper e.- Type Parameters:
E- the type parameter- Parameters:
operation- the operationerrorMessage- the error message- Returns:
- the e
-
ioWrapper
public static <E> E ioWrapper(@NotNull @NotNull SupplierIO<E> operation, @NotNull @NotNull java.util.function.Supplier<java.lang.String> errorMessage)Io wrapper e.- Type Parameters:
E- the type parameter- Parameters:
operation- the operationerrorMessage- the error message- Returns:
- the e
-
ioOptional
public static <E> java.util.Optional<E> ioOptional(@Nullable @Nullable SupplierIO<E> operation)Io optional optional.- Type Parameters:
E- the type parameter- Parameters:
operation- the operation- Returns:
- the optional
-
ioWrapper
public static <E> void ioWrapper(@Nullable E input, @NotNull @NotNull ConsumerIO<E> operation, @NotNull @NotNull java.lang.String errorMessage)Io wrapper.- Type Parameters:
E- the type parameter- Parameters:
input- the inputoperation- the operationerrorMessage- the error message
-
ioWrapper
public static <E> void ioWrapper(@Nullable E input, @NotNull @NotNull ConsumerIO<E> operation)Io wrapper.- Type Parameters:
E- the type parameter- Parameters:
input- the inputoperation- the operation
-
ioWrapper
public static <E> void ioWrapper(@Nullable E input, @NotNull @NotNull ConsumerIO<E> operation, @NotNull @NotNull java.util.function.Supplier<java.lang.String> errorMessage)Io wrapper.- Type Parameters:
E- the type parameter- Parameters:
input- the inputoperation- the operationerrorMessage- the error message
-
writerWrapper
public static RunnableIO writerWrapper(@NotNull @NotNull java.io.File file, @NotNull @NotNull java.util.function.Supplier<java.lang.String> textToWrite)
Writer wrapper runnable io.- Parameters:
file- the filetextToWrite- the text to write- Returns:
- the runnable io
-
-