本文整理汇总了Java中org.xml.sax.ContentHandler.toString方法的典型用法代码示例。如果您正苦于以下问题:Java ContentHandler.toString方法的具体用法?Java ContentHandler.toString怎么用?Java ContentHandler.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xml.sax.ContentHandler
的用法示例。
在下文中一共展示了ContentHandler.toString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractText
import org.xml.sax.ContentHandler; //导入方法依赖的package包/类
@Override
public void extractText(String mimeType, InputStream input, StringBuilder outputText, int maxSize)
throws IOException
{
try
{
Metadata meta = new Metadata();
ContentHandler handler = new BodyContentHandler();
Parser parser = new AutoDetectParser(new TikaConfig(getClass().getClassLoader()));
parser.parse(input, handler, meta, new ParseContext());
String content = handler.toString();
if( content.length() > maxSize )
{
content = content.substring(0, maxSize);
}
outputText.append(content);
if( LOGGER.isDebugEnabled() )
{
LOGGER.debug("Word Summary:" + content); //$NON-NLS-1$
}
}
catch( Exception e )
{
throw new RuntimeException(e);
}
}
示例2: appendText
import org.xml.sax.ContentHandler; //导入方法依赖的package包/类
private void appendText(ContentHandler handler, StringBuilder outputText, int maxSize)
{
String pdfSummary = handler.toString();
if( pdfSummary.length() > maxSize )
{
pdfSummary = pdfSummary.substring(0, maxSize);
}
outputText.append(pdfSummary);
if( LOGGER.isTraceEnabled() )
{
LOGGER.trace("PDF Summary:" + pdfSummary);
}
}
示例3: extractText
import org.xml.sax.ContentHandler; //导入方法依赖的package包/类
@Override
public void extractText(String mimeType, InputStream input, StringBuilder outputText, int maxSize)
throws IOException
{
try
{
Metadata meta = new Metadata();
ContentHandler handler = new BodyContentHandler();
Parser parser = new AutoDetectParser(new TikaConfig(getClass().getClassLoader()));
parser.parse(input, handler, meta, new ParseContext());
String content = handler.toString();
if( content.length() > maxSize )
{
content = content.substring(0, maxSize);
}
outputText.append(content);
if( LOGGER.isDebugEnabled() )
{
LOGGER.debug("Excel Summary:" + content); //$NON-NLS-1$
}
}
catch( Exception e )
{
// Do nothing
}
}
示例4: parse
import org.xml.sax.ContentHandler; //导入方法依赖的package包/类
private static String parse(final InputStream input) throws TikaException, SAXException, IOException {
final Parser parser = new PDFParser();
final ContentHandler handler = new BodyContentHandler();
final Metadata metadata = new Metadata();
final ParseContext parseContext = new ParseContext();
parser.parse(input, handler, metadata, parseContext);
return handler.toString();
}