Class ResourceConverter


  • @Component("tapirResourceConverter")
    public class ResourceConverter
    extends java.lang.Object
    A set of methods which are useful in order to handle files and resources in general.
    Since:
    2.0.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.File toFile​(java.io.InputStream inputStream, java.lang.String prefix, java.lang.String suffix)
      Converts the given inputstream to a temporary file
      java.io.File toFile​(java.lang.CharSequence charSequence, java.nio.charset.Charset charset, java.lang.String prefix, java.lang.String suffix)
      Converts the given charSequence to a temporary file
      java.lang.String toHtmlFileURI​(java.io.InputStream htmlInputStream)
      Converts the given HTML inputstream to a temporary file
      java.lang.String toHtmlFileURI​(java.lang.CharSequence htmlCode, java.nio.charset.Charset charset)
      Converts the given HTML code to a temporary file
      java.io.File toTempFolder​(java.lang.String classPathFolder)
      Copies a classpath folder to a temp folder and returns the temp folder
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ResourceConverter

        public ResourceConverter()
    • Method Detail

      • toFile

        public java.io.File toFile​(java.lang.CharSequence charSequence,
                                   java.nio.charset.Charset charset,
                                   java.lang.String prefix,
                                   java.lang.String suffix)
                            throws java.io.IOException
        Converts the given charSequence to a temporary file
        Parameters:
        charSequence - the charSequence which should be written to a file
        charset - the charset to use, null means platform default
        prefix - temp file prefix
        suffix - temp file suffix
        Returns:
        the file containing the charSequence
        Throws:
        java.io.IOException - in case of an I/O error
        Since:
        2.0.0
      • toFile

        public java.io.File toFile​(java.io.InputStream inputStream,
                                   java.lang.String prefix,
                                   java.lang.String suffix)
                            throws java.io.IOException
        Converts the given inputstream to a temporary file
        Parameters:
        inputStream - the inputStream which should be written to a file
        prefix - temp file prefix
        suffix - temp file suffix
        Returns:
        the file containing the inputStream
        Throws:
        java.io.IOException - in case of an I/O error
        Since:
        2.0.0
      • toHtmlFileURI

        public java.lang.String toHtmlFileURI​(java.lang.CharSequence htmlCode,
                                              java.nio.charset.Charset charset)
                                       throws java.io.IOException
        Converts the given HTML code to a temporary file
        Parameters:
        htmlCode - the HTML code which should be written to a file
        charset - the charset to use, null means platform default
        Returns:
        the file containing the HTML code
        Throws:
        java.io.IOException - in case of an I/O error
        Since:
        2.0.0
      • toHtmlFileURI

        public java.lang.String toHtmlFileURI​(java.io.InputStream htmlInputStream)
                                       throws java.io.IOException
        Converts the given HTML inputstream to a temporary file
        Parameters:
        htmlInputStream - the HTML inputstream which should be written to a file
        Returns:
        the file containing the HTML code
        Throws:
        java.io.IOException - in case of an I/O error
        Since:
        2.0.0
      • toTempFolder

        public java.io.File toTempFolder​(java.lang.String classPathFolder)
                                  throws java.io.IOException
        Copies a classpath folder to a temp folder and returns the temp folder
        Parameters:
        classPathFolder - the folder in the classpath which should be copied
        Returns:
        the temp folder
        Throws:
        java.io.IOException - in case of an I/O error
        Since:
        2.0.0