示例#1
0
 public String filter(InputStream in) {
   if (in == null) return null;
   try {
     SAXParser parser = new SAXParser();
     HTMLHandler contentHandler = new HTMLHandler((int) (1000 * 0.66f));
     parser.setContentHandler(contentHandler);
     parser.parse(new InputSource(in));
     return contentHandler.toString();
   } catch (SAXException e) {
     log.error("", e);
     return null;
   } catch (IOException e) {
     log.error("", e);
     return null;
   } catch (Exception e) {
     log.error("", e);
     return null;
   }
 }
示例#2
0
 @Override
 public String filter(String original) {
   if (original == null) return null;
   try {
     SAXParser parser = new SAXParser();
     HTMLHandler contentHandler = new HTMLHandler((int) (original.length() * 0.66f));
     parser.setContentHandler(contentHandler);
     parser.parse(new InputSource(new StringReader(original)));
     return contentHandler.toString();
   } catch (SAXException e) {
     log.error("", e);
     return null;
   } catch (IOException e) {
     log.error("", e);
     return null;
   } catch (Exception e) {
     log.error("", e);
     return null;
   }
 }