FileDocCategorySizeDatePackage
LineBreakingTagStripper.javaAPI DocExample1975Sat Sep 09 19:55:28 BST 2000None

LineBreakingTagStripper

public class LineBreakingTagStripper extends HTMLEditorKit$ParserCallback

Fields Summary
private Writer
out
private String
lineSeparator
Constructors Summary
public LineBreakingTagStripper(Writer out)

    this(out, System.getProperty("line.separator", "\r\n")); 
  
public LineBreakingTagStripper(Writer out, String lineSeparator)

    this.out = out; 
    this.lineSeparator = lineSeparator;
  
Methods Summary
public voidhandleEndTag(javax.swing.text.html.HTML$Tag tag, int position)


    try {
      if (tag.isBlock()) {
        out.write(lineSeparator);
        out.write(lineSeparator);
      }
      else if (tag.breaksFlow()) {
        out.write(lineSeparator);
      }
    }
    catch (IOException e) {
      System.err.println(e); 
    }
    
  
public voidhandleSimpleTag(javax.swing.text.html.HTML$Tag tag, javax.swing.text.MutableAttributeSet attributes, int position)

    
    try {
      if (tag.isBlock()) {
        out.write(lineSeparator);
        out.write(lineSeparator);
      }
      else if (tag.breaksFlow()) {
        out.write(lineSeparator);
      }
      else {
        out.write(' "); 
      }
    }
    catch (IOException e) {
      System.err.println(e); 
    }
 
  
public voidhandleText(char[] text, int position)

    try {
      out.write(text);
      out.flush();
    }
    catch (IOException e) {
      System.err.println(e); 
    }
  
public static voidmain(java.lang.String[] args)

    
    ParserGetter kit = new ParserGetter();
    HTMLEditorKit.Parser parser = kit.getParser();
    HTMLEditorKit.ParserCallback callback 
     = new LineBreakingTagStripper(new OutputStreamWriter(System.out));
    
    try {
      URL u = new URL(args[0]);
      InputStream in = u.openStream();
      InputStreamReader r = new InputStreamReader(in);
      parser.parse(r, callback, false);
    }
    catch (IOException e) {
      System.err.println(e); 
    }