Package org.azd.helpers
Class StreamHelper
java.lang.Object
org.azd.helpers.StreamHelper
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
convertStreamToBase64
(InputStream content) Converts the Input stream to base64 encoded string value.static InputStream
convertToStream
(File file) Convert the file contents to input streamstatic InputStream
convertToStream
(String content) Convert the string content to input streamstatic String
convertToString
(InputStream responseStream) Convert the InputStream stream to stringstatic void
download
(String fileName, InputStream responseStream) Downloads the contents from InputStream and saves it in a file.static void
downloadFromUrl
(String url, String fileName) Helper method to download the contents stream from a url.static int
Returns the default byte array sizestatic void
setDefaultByteArraySize
(int defaultByteArraySize) Sets the byte array size
-
Constructor Details
-
StreamHelper
public StreamHelper()
-
-
Method Details
-
getDefaultByteArraySize
public static int getDefaultByteArraySize()Returns the default byte array size- Returns:
- Default byte array size
-
setDefaultByteArraySize
public static void setDefaultByteArraySize(int defaultByteArraySize) Sets the byte array size- Parameters:
defaultByteArraySize
- Size of the byte array to set
-
download
Downloads the contents from InputStream and saves it in a file.- Parameters:
fileName
- Pass the full path with file name to save the contents.responseStream
- Input response stream from Api or from a file.- Throws:
AzDException
- Default exception handler
-
downloadFromUrl
Helper method to download the contents stream from a url.- Parameters:
url
- Provide the URL to download the contents from.fileName
- Full path along with file name to download the contents from URL.- Throws:
AzDException
- Default Api exception handler.
-
convertToString
Convert the InputStream stream to string- Parameters:
responseStream
- Input response stream from Api or from a file.- Returns:
- String content
- Throws:
AzDException
- Default exception handler
-
convertToStream
Convert the file contents to input stream- Parameters:
file
- File object specified with complete path- Returns:
- Input stream
- Throws:
AzDException
- Default exception handler
-
convertToStream
Convert the string content to input stream- Parameters:
content
- String content to convert- Returns:
- Input stream
- Throws:
AzDException
- Default exception handler
-
convertStreamToBase64
Converts the Input stream to base64 encoded string value.- Parameters:
content
- InputStream of contents.- Returns:
- Base64 encoded String contents.
- Throws:
AzDException
- Default Api exception handler.
-