Package de.bmiag.tapir.test
Class ResourceConverter
- java.lang.Object
-
- de.bmiag.tapir.test.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
-
-
Constructor Summary
Constructors Constructor Description ResourceConverter()
-
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 filejava.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 filejava.lang.String
toHtmlFileURI(java.io.InputStream htmlInputStream)
Converts the given HTML inputstream to a temporary filejava.lang.String
toHtmlFileURI(java.lang.CharSequence htmlCode, java.nio.charset.Charset charset)
Converts the given HTML code to a temporary filejava.io.File
toTempFolder(java.lang.String classPathFolder)
Copies a classpath folder to a temp folder and returns the temp folder
-
-
-
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 filecharset
- the charset to use,null
means platform defaultprefix
- temp file prefixsuffix
- 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 fileprefix
- temp file prefixsuffix
- 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 filecharset
- 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
-
-