Package fr.flowarg.flowupdater.utils
Class IOUtils
java.lang.Object
fr.flowarg.flowupdater.utils.IOUtils
A basic I/O utility class.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamcatchForbidden(@NotNull URL url) A trick to avoid some forbidden response.static voidCopy a local file to a destination file.static voidDownload a remote file to a destination file.static <T> voidexecuteAsyncForEach(@NotNull Iterable<T> iterable, @NotNull ExecutorService service, Consumer<T> runnable) Execute asynchronously a task for a collection of items.static @NotNull StringgetContent(InputStream remote) Get the content from a remote stream.static @NotNull StringgetContent(URL url) Get the content from a remote url.static StringgetLatestArtifactVersion(@NotNull Document doc) static @Nullable StringgetLatestArtifactVersion(String mavenMetadataUrl) static PathRetrieve the local Minecraft folder path.static com.google.gson.JsonElementreadJson(InputStream inputStream) Reading an inputStream in a json elementstatic com.google.gson.JsonElementReading an url in a json element
-
Constructor Details
-
IOUtils
public IOUtils()
-
-
Method Details
-
download
public static void download(@NotNull @NotNull fr.flowarg.flowlogger.ILogger logger, @NotNull @NotNull URL in, @NotNull @NotNull Path out) Download a remote file to a destination file.- Parameters:
logger- a valid logger instance.in- the input url.out- the output file.
-
copy
public static void copy(@NotNull @NotNull fr.flowarg.flowlogger.ILogger logger, @NotNull @NotNull Path in, @NotNull @NotNull Path out) Copy a local file to a destination file.- Parameters:
logger- a valid logger instance.in- the input file.out- the output file.
-
getContent
Get the content from a remote url.- Parameters:
url- the destination url- Returns:
- the content.
-
getContent
Get the content from a remote stream.- Parameters:
remote- the remote stream- Returns:
- the content.
-
readJson
Reading an url in a json element- Parameters:
jsonURL- json input- Returns:
- a json element
-
readJson
Reading an inputStream in a json element- Parameters:
inputStream- json input- Returns:
- a json element
-
catchForbidden
A trick to avoid some forbidden response.- Parameters:
url- the destination url.- Returns:
- the opened connection.
- Throws:
Exception- if an I/O error occurred.
-
executeAsyncForEach
public static <T> void executeAsyncForEach(@NotNull @NotNull Iterable<T> iterable, @NotNull @NotNull ExecutorService service, Consumer<T> runnable) Execute asynchronously a task for a collection of items.- Type Parameters:
T- the type of the items.- Parameters:
iterable- the collection of items.service- the executor service.runnable- the task to execute.
-
getLatestArtifactVersion
-
getLatestArtifactVersion
-
getMinecraftFolder
Retrieve the local Minecraft folder path.- Returns:
- the Minecraft folder path.
-