Package nva.commons.core.ioutils
Class IoUtils
- java.lang.Object
-
- nva.commons.core.ioutils.IoUtils
-
public final class IoUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringLINE_SEPARATORstatic java.lang.StringPATH_SEPARATOR_FOR_RESOURCESstatic java.lang.StringWIN_PATH_SEPARATOR_REGEX
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.io.InputStreaminputStreamFromResources(java.lang.String path)Read resource file as anInputStream.static java.io.InputStreaminputStreamFromResources(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.StringstreamToString(java.io.InputStream stream)Return a String the stream data encoded in UTF-8.static java.lang.StringstringFromFile(java.nio.file.Path path)Read file as aString.static java.lang.StringstringFromResources(java.nio.file.Path path)Read resource file as aStringThe 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.InputStreamstringToStream(java.lang.String input)Tranform a string to an inputStream.
-
-
-
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 anInputStream. 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 anInputStream. 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- theInputStream- Returns:
- the output String.
-
stringFromFile
public static java.lang.String stringFromFile(java.nio.file.Path path)
Read file as aString. Encoding is UTF-8. New lines are being preserved.- Parameters:
path-Pathto 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 aStringThe 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
Stringwith 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- aString- Returns:
- a
InputStream
-
-