Class ResourceUtil
java.lang.Object
nl.siegmann.epublib.util.ResourceUtil
Various resource utility methods
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ResourcecreateResource(File file) static ResourcecreateResource(String title, String href) Creates a resource with as contents a html page with the given title.static ResourcecreateResource(ZipEntry zipEntry, InputStream zipInputStream) static ResourcecreateResource(ZipEntry zipEntry, ZipInputStream zipInputStream) Creates a resource out of the given zipEntry and zipInputStream.static DocumentgetAsDocument(Resource resource) Reads parses the xml therein and returns the result as a Documentstatic DocumentgetAsDocument(Resource resource, DocumentBuilder documentBuilder) Reads the given resources inputstream, parses the xml therein and returns the result as a Documentstatic InputSourcegetInputSource(Resource resource) Gets the contents of the Resource as an InputSource in a null-safe manner.static byte[]Converts a given string from given input character encoding to the requested output character encoding.
-
Constructor Details
-
ResourceUtil
public ResourceUtil()
-
-
Method Details
-
createResource
- Throws:
IOException
-
createResource
-
createResource
public static Resource createResource(ZipEntry zipEntry, ZipInputStream zipInputStream) throws IOException Creates a resource out of the given zipEntry and zipInputStream.- Parameters:
zipEntry-zipInputStream-- Returns:
- a resource created out of the given zipEntry and zipInputStream.
- Throws:
IOException
-
createResource
public static Resource createResource(ZipEntry zipEntry, InputStream zipInputStream) throws IOException - Throws:
IOException
-
recode
public static byte[] recode(String inputEncoding, String outputEncoding, byte[] input) throws UnsupportedEncodingException Converts a given string from given input character encoding to the requested output character encoding.- Parameters:
inputEncoding-outputEncoding-input-- Returns:
- the string from given input character encoding converted to the requested output character encoding.
- Throws:
UnsupportedEncodingException
-
getInputSource
Gets the contents of the Resource as an InputSource in a null-safe manner.- Throws:
IOException
-
getAsDocument
public static Document getAsDocument(Resource resource) throws UnsupportedEncodingException, SAXException, IOException, ParserConfigurationException Reads parses the xml therein and returns the result as a Document -
getAsDocument
public static Document getAsDocument(Resource resource, DocumentBuilder documentBuilder) throws UnsupportedEncodingException, SAXException, IOException, ParserConfigurationException Reads the given resources inputstream, parses the xml therein and returns the result as a Document- Parameters:
resource-documentBuilder-- Returns:
- the document created from the given resource
- Throws:
UnsupportedEncodingExceptionSAXExceptionIOExceptionParserConfigurationException
-