Solved

ChangedCharSetException From Swing Parser

Posted on 2004-04-13
7
827 Views
Last Modified: 2011-09-20
Hi,
I am trying to parse through the HTML tags using the swing HTML parser.  The problem is that a ChangedCharSetException is thrown when I try to read from certain html files.  I am not quite sure how to go around this.  Thanks for any comments.


HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback(){
    public void handleStartTag(HTML.Tag tag, MutableAttributeSet aSet, int pos){
        <some code>
    }
    public void handleSimpleTag(HTML.Tag tag, MutableAttributeSet aSet, int pos){
        <some code>
    }
};

Reader in = new FileReader(file);
new ParserDelegator().parse(in, callback, false);
0
Comment
Question by:aomega
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 4

Accepted Solution

by:
bkfirebird earned 125 total points
ID: 10819342
htmlDoc.putProperties("IgnoreCharacterSet",boolean(true));
HTMLEditorKit class cannot interpret <meta> tags as HTML content ..
0
 
LVL 92

Expert Comment

by:objects
ID: 10819401
think you meant:
doc.putProperty("IgnoreCharsetDirective", new Boolean(true));

But what is the htmlDoc you are calling?
0
 
LVL 4

Expert Comment

by:bkfirebird
ID: 10819462
i was referring to the default document ...

i guess a simpler way to do it would be to specify in parse() itself ... change last param to true
new ParserDelegator().parse(in, callback, true);
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:aomega
ID: 10819878
Thanks
0
 
LVL 92

Expert Comment

by:objects
ID: 10819893
can you post exactly what you used for the benefit of others.
0
 

Author Comment

by:aomega
ID: 10821354
No problem.

EditorKit kit = new HTMLEditorKit();
Document doc = kit.createDefaultDocument();
doc.putProperty("IgnoreCharsetDirective", new Boolean(true));

kit.read(reader, doc, true);


I actually implemented this by changing the last param to true as bkfirebird pointed out since that was easier: new ParserDelegator().parse(in, callback, true);
0
 
LVL 92

Expert Comment

by:objects
ID: 10821372
Thanks :)
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question