Class IoUtils


  • public final class IoUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static java.io.InputStream inputStreamFromResources​(java.lang.String path)
      Read resource file as an InputStream.
      static java.io.InputStream inputStreamFromResources​(java.nio.file.Path path)
      Deprecated.
      static java.util.List<java.lang.String> linesfromResource​(java.nio.file.Path path)
      Read resource file as a List of Strings.
      static java.lang.String streamToString​(java.io.InputStream stream)
      Return a String the stream data encoded in UTF-8.
      static java.lang.String stringFromFile​(java.nio.file.Path path)
      Read file as a String.
      static java.lang.String stringFromResources​(java.nio.file.Path path)
      Read resource file as a String The root folder for the resources is considered to be the folders src/main/resources and src/test/resources/, or any other standard resources folder.
      static java.io.InputStream stringToStream​(java.lang.String input)
      Tranform a string to an inputStream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LINE_SEPARATOR

        public static final java.lang.String LINE_SEPARATOR
      • WIN_PATH_SEPARATOR_REGEX

        public static final java.lang.String WIN_PATH_SEPARATOR_REGEX
        See Also:
        Constant Field Values
      • PATH_SEPARATOR_FOR_RESOURCES

        public static final java.lang.String PATH_SEPARATOR_FOR_RESOURCES
        See Also:
        Constant Field Values
    • Method Detail

      • inputStreamFromResources

        @Deprecated
        public static java.io.InputStream inputStreamFromResources​(java.nio.file.Path path)
        Deprecated.
        Read resource file as an InputStream. The root folder for the resources is considered to be the folders src/main/resources and src/test/resources/, or any other standard reosources folder.
        Parameters:
        path - the Path to the resource.
        Returns:
        an InputStream with the data.
      • inputStreamFromResources

        public static java.io.InputStream inputStreamFromResources​(java.lang.String path)
        Read resource file as an InputStream. The root folder for the resources is considered to be the folders src/main/resources and src/test/resources/, or any other standard reosources folder.
        Parameters:
        path - the path to the resource.
        Returns:
        an InputStream with the data.
      • streamToString

        public static java.lang.String streamToString​(java.io.InputStream stream)
        Return a String the stream data encoded in UTF-8.
        Parameters:
        stream - the InputStream
        Returns:
        the output String.
      • stringFromFile

        public static java.lang.String stringFromFile​(java.nio.file.Path path)
        Read file as a String. Encoding is UTF-8. New lines are being preserved.
        Parameters:
        path - Path to the file
        Returns:
        the content of the file in a String.
      • linesfromResource

        public static java.util.List<java.lang.String> linesfromResource​(java.nio.file.Path path)
        Read resource file as a List of Strings. The root folder for the resources is considered to be the folders src/main/resources and src/test/resources/, or any other standard resources folder. Each element of the list contains a line of the file.
        Parameters:
        path - the Path to the resource.
        Returns:
        a List with the lines of the file.
      • stringFromResources

        public static java.lang.String stringFromResources​(java.nio.file.Path path)
        Read resource file as a String The root folder for the resources is considered to be the folders src/main/resources and src/test/resources/, or any other standard resources folder. New lines in the resource file are preserved
        Parameters:
        path - the Path to the resource.
        Returns:
        a String with the contents of the file.
      • stringToStream

        public static java.io.InputStream stringToStream​(java.lang.String input)
        Tranform a string to an inputStream. Encoding is UTF-8.
        Parameters:
        input - a String
        Returns:
        a InputStream