This article will helps you to Extract a Text from a Html Stringin J2me using HtmlComponent.You need to Provide the Input as Html String to this Sample Example.Then the output will be Pure Text.
Check the Sample Code Below:
Note:
1)If you have an Image tag in Html String.Then you can also display an Image on Screen by Using the below Statement
//com.setShowImages(true);
2)To execute the above Application you need LWUIT jar file.You can download the jar file Here
Check the Sample Code Below:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.html.HTMLComponent;
import javax.microedition.midlet.MIDlet;
/**
* @author pavan
*/
public class HtmlMidlet extends MIDlet {
public void startApp() {
Display.init(this);
Form f = new Form("HtmlComponent");
String html = "<p>HTMl Text Extraction </P><p>Html Text Extraction</p>";
HTMLComponent com = new HTMLComponent();
com.setBodyText(html);
f.addComponent(com);
f.show();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
Note:
1)If you have an Image tag in Html String.Then you can also display an Image on Screen by Using the below Statement
//com.setShowImages(true);
2)To execute the above Application you need LWUIT jar file.You can download the jar file Here