Class IOUtils

java.lang.Object
fr.flowarg.flowupdater.utils.IOUtils

public class IOUtils extends Object
A basic I/O utility class.
  • 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

      @NotNull public static @NotNull String getContent(URL url)
      Get the content from a remote url.
      Parameters:
      url - the destination url
      Returns:
      the content.
    • getContent

      @NotNull public static @NotNull String getContent(InputStream remote)
      Get the content from a remote stream.
      Parameters:
      remote - the remote stream
      Returns:
      the content.
    • readJson

      public static com.google.gson.JsonElement readJson(URL jsonURL)
      Reading an url in a json element
      Parameters:
      jsonURL - json input
      Returns:
      a json element
    • readJson

      public static com.google.gson.JsonElement readJson(InputStream inputStream)
      Reading an inputStream in a json element
      Parameters:
      inputStream - json input
      Returns:
      a json element
    • catchForbidden

      public static InputStream catchForbidden(@NotNull @NotNull URL url) throws Exception
      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

      @Nullable public static @Nullable String getLatestArtifactVersion(String mavenMetadataUrl)
    • getLatestArtifactVersion

      public static String getLatestArtifactVersion(@NotNull @NotNull Document doc)
    • getMinecraftFolder

      public static Path getMinecraftFolder()
      Retrieve the local Minecraft folder path.
      Returns:
      the Minecraft folder path.