Class StreamHelper

java.lang.Object
org.azd.helpers.StreamHelper

public class StreamHelper extends Object
  • 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

      public static void download(String fileName, InputStream responseStream) throws AzDException
      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

      public static void downloadFromUrl(String url, String fileName) throws AzDException
      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

      public static String convertToString(InputStream responseStream) throws AzDException
      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

      public static InputStream convertToStream(File file) throws AzDException
      Convert the file contents to input stream
      Parameters:
      file - File object specified with complete path
      Returns:
      Input stream
      Throws:
      AzDException - Default exception handler
    • convertToStream

      public static InputStream convertToStream(String content) throws AzDException
      Convert the string content to input stream
      Parameters:
      content - String content to convert
      Returns:
      Input stream
      Throws:
      AzDException - Default exception handler
    • convertStreamToBase64

      public static String convertStreamToBase64(InputStream content) throws AzDException
      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.