本文整理汇总了Java中nl.siegmann.epublib.domain.Resource.setInputEncoding方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.setInputEncoding方法的具体用法?Java Resource.setInputEncoding怎么用?Java Resource.setInputEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nl.siegmann.epublib.domain.Resource
的用法示例。
在下文中一共展示了Resource.setInputEncoding方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadResources
import nl.siegmann.epublib.domain.Resource; //导入方法依赖的package包/类
/**
* Loads all entries from the ZipInputStream as Resources.
*
* Loads the contents of all ZipEntries into memory.
* Is fast, but may lead to memory problems when reading large books on devices with small amounts of memory.
*
* @param zipInputStream
* @param defaultHtmlEncoding
* @return
* @throws IOException
*/
public static Resources loadResources(ZipInputStream zipInputStream, String defaultHtmlEncoding) throws IOException {
Resources result = new Resources();
ZipEntry zipEntry;
do {
// get next valid zipEntry
zipEntry = getNextZipEntry(zipInputStream);
if((zipEntry == null) || (zipEntry == ERROR_ZIP_ENTRY) || zipEntry.isDirectory()) {
continue;
}
// store resource
Resource resource = ResourceUtil.createResource(zipEntry, zipInputStream);
if(resource.getMediaType() == MediatypeService.XHTML) {
resource.setInputEncoding(defaultHtmlEncoding);
}
result.add(resource);
} while(zipEntry != null);
return result;
}
示例2: cleanupResource
import nl.siegmann.epublib.domain.Resource; //导入方法依赖的package包/类
private void cleanupResource(Resource resource, Book book) throws IOException {
if(resource.getMediaType() == MediatypeService.XHTML) {
byte[] cleanedHtml = processHtml(resource, book, Constants.CHARACTER_ENCODING);
resource.setData(cleanedHtml);
resource.setInputEncoding(Constants.CHARACTER_ENCODING);
}
}
示例3: createResource
import nl.siegmann.epublib.domain.Resource; //导入方法依赖的package包/类
public static Resource createResource(FileObject rootDir, FileObject file, String inputEncoding) throws IOException {
MediaType mediaType = MediatypeService.determineMediaType(file.getName().getBaseName());
if(mediaType == null) {
return null;
}
String href = calculateHref(rootDir, file);
Resource result = new Resource(null, IOUtils.toByteArray(file.getContent().getInputStream()), href, mediaType);
result.setInputEncoding(inputEncoding);
return result;
}