Class IOUtils

java.lang.Object
io.micronaut.core.io.IOUtils

public class IOUtils extends Object
Utility methods for I/O operations.
Since:
1.0
Author:
Graeme Rocher
  • Constructor Details

    • IOUtils

      public IOUtils()
  • Method Details

    • eachFile

      public static void eachFile(@NonNull @NonNull URL url, String path, @NonNull @NonNull Consumer<Path> consumer)
      Iterates over each directory in a JAR or file system.
      Parameters:
      url - The URL
      path - The path
      consumer - The consumer
      Since:
      3.5.0
    • eachFile

      public static void eachFile(@NonNull @NonNull URI uri, String path, @NonNull @NonNull Consumer<Path> consumer)
      Iterates over each directory in a JAR or file system.
      Parameters:
      uri - The URI
      path - The path
      consumer - The consumer
      Since:
      3.5.0
    • resolvePath

      @Nullable public static @Nullable Path resolvePath(@NonNull @NonNull URI uri, @NonNull @NonNull String path, @NonNull @NonNull List<Closeable> toClose) throws IOException
      Resolve the path in the URI.
      Parameters:
      uri - The URI
      path - The path
      toClose - to close hooks
      Returns:
      The path resolved
      Throws:
      IOException
      Since:
      4.7
    • readText

      public static String readText(BufferedReader reader) throws IOException
      Read the content of the BufferedReader and return it as a String in a blocking manner. The BufferedReader is closed afterward.
      Parameters:
      reader - a BufferedReader whose content we want to read
      Returns:
      a String containing the content of the buffered reader
      Throws:
      IOException - if an IOException occurs.
      Since:
      1.0
    • getResources

      public static List<URI> getResources(ClassLoader classLoader, String path) throws IOException
      Find all the resources starting with the path.
      Parameters:
      classLoader - The classloader
      path - The path
      Returns:
      the resources as URIs
      Throws:
      IOException - The IO exception
      Since:
      4.7