本文整理匯總了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();
}