Package org.brijframework.util.location
Class StreamUtil
- java.lang.Object
-
- org.brijframework.util.location.StreamUtil
-
public class StreamUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static intBUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description StreamUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcopy(byte[] in, OutputStream out)Copy the contents of the given byte array to the given OutputStream.static intcopy(InputStream in, OutputStream out)Copy the contents of the given InputStream to the given OutputStream.static voidcopy(String in, Charset charset, OutputStream out)Copy the contents of the given String to the given output OutputStream.static byte[]copyToByteArray(InputStream in)Copy the contents of the given InputStream into a new byte array.static StringcopyToString(InputStream in, Charset charset)Copy the contents of the given InputStream into a String.static File[]getAllResurces(String path, String extension)static InputStreamgetConfigStream(String path)static StringgetResource(String resourse)static InputStreamgetResourceAsStream(String resource)static InputStreamgetUserResourceAsStream(String resource)static StringloadFromStream(InputStream io)static byte[]loadInBufferModeFromStream(InputStream inputStream)static InputStreamnonClosing(InputStream in)Returns a variant of the givenInputStreamwhere callingclose()has no effect.static OutputStreamnonClosing(OutputStream out)Returns a variant of the givenOutputStreamwhere callingclose()has no effect.static <T> TreadJsonFromFile(Path path, com.fasterxml.jackson.core.type.TypeReference<T> valueType)static booleanwriteJsonToFile(Path path, Object data)
-
-
-
Field Detail
-
BUFFER_SIZE
public static final int BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getConfigStream
public static InputStream getConfigStream(String path)
-
getResourceAsStream
public static InputStream getResourceAsStream(String resource)
-
getUserResourceAsStream
public static InputStream getUserResourceAsStream(String resource)
-
loadFromStream
public static String loadFromStream(InputStream io)
-
loadInBufferModeFromStream
public static byte[] loadInBufferModeFromStream(InputStream inputStream) throws IOException
- Throws:
IOException
-
copyToByteArray
public static byte[] copyToByteArray(InputStream in) throws IOException
Copy the contents of the given InputStream into a new byte array. Leaves the stream open when done.- Parameters:
in- the stream to copy from- Returns:
- the new byte array that has been copied to
- Throws:
IOException- in case of I/O errors
-
copyToString
public static String copyToString(InputStream in, Charset charset) throws IOException
Copy the contents of the given InputStream into a String. Leaves the stream open when done.- Parameters:
in- the InputStream to copy from- Returns:
- the String that has been copied to
- Throws:
IOException- in case of I/O errors
-
copy
public static void copy(byte[] in, OutputStream out) throws IOExceptionCopy the contents of the given byte array to the given OutputStream. Leaves the stream open when done.- Parameters:
in- the byte array to copy fromout- the OutputStream to copy to- Throws:
IOException- in case of I/O errors
-
copy
public static void copy(String in, Charset charset, OutputStream out) throws IOException
Copy the contents of the given String to the given output OutputStream. Leaves the stream open when done.- Parameters:
in- the String to copy fromcharset- the Charsetout- the OutputStream to copy to- Throws:
IOException- in case of I/O errors
-
copy
public static int copy(InputStream in, OutputStream out) throws IOException
Copy the contents of the given InputStream to the given OutputStream. Leaves both streams open when done.- Parameters:
in- the InputStream to copy fromout- the OutputStream to copy to- Returns:
- the number of bytes copied
- Throws:
IOException- in case of I/O errors
-
nonClosing
public static InputStream nonClosing(InputStream in)
Returns a variant of the givenInputStreamwhere callingclose()has no effect.- Parameters:
in- the InputStream to decorate- Returns:
- a version of the InputStream that ignores calls to close
-
nonClosing
public static OutputStream nonClosing(OutputStream out)
Returns a variant of the givenOutputStreamwhere callingclose()has no effect.- Parameters:
out- the OutputStream to decorate- Returns:
- a version of the OutputStream that ignores calls to close
-
readJsonFromFile
public static <T> T readJsonFromFile(Path path, com.fasterxml.jackson.core.type.TypeReference<T> valueType)
-
-