Package nva.commons.core.ioutils
Class IoUtils
java.lang.Object
nva.commons.core.ioutils.IoUtils
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamRead resource file as anInputStream.static InputStreaminputStreamFromResources(Path path) Deprecated.static byte[]inputStreamToBytes(InputStream inputStream) linesfromResource(Path path) Read resource file as a List of Strings.static StringpathToString(Path path) static StringstreamToString(InputStream stream) Return a String the stream data encoded in UTF-8.static StringstringFromFile(Path path) Read file as aString.static StringstringFromResources(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 InputStreamstringToStream(String input) Tranform a string to an inputStream.
-
Field Details
-
LINE_SEPARATOR
-
WIN_PATH_SEPARATOR_REGEX
- See Also:
-
PATH_SEPARATOR_FOR_RESOURCES
- See Also:
-
ROOT
- See Also:
-
-
Method Details
-
inputStreamFromResources
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
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.The resource is first looked up via the thread context class loader, falling back to the class loader that loaded this class. The fallback is required on threads whose context class loader cannot see application classes, such as
ForkJoinPoolcommon-pool workers on AWS Lambda.- Parameters:
path- the path to the resource.- Returns:
- an InputStream with the data.
-
pathToString
-
streamToString
Return a String the stream data encoded in UTF-8.- Parameters:
stream- theInputStream- Returns:
- the output String.
-
stringFromFile
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
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
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
Tranform a string to an inputStream. Encoding is UTF-8.- Parameters:
input- aString- Returns:
- a
InputStream
-
inputStreamToBytes
- Throws:
IOException
-