You can implement javax.microedition.io.HttpConnection interface so that it takes your text like this.
Code:
public class HttpConnectionImpl implements HttpConnection {
private DataInputStream dataInput;
private InputStream in;
private String encoding = "text/html";
public HttpConnectionImpl(String text) {
try {
in = new ByteArrayInputStream(text.getBytes("UTF-8"));
dataInput = new DataInputStream(in);
} catch (Exception e) {
System.out.println("HttpConnectionImpl : Exception : " + e);
}
}
// implement rest of the methods of HttpConnection interface with dummy methods
}
Then you can pass an object of this implementation to get the field as follows;
Code:
String text= "This is a test.";
HttpConnection connection = new HttpConnectionImpl(text);
renderingSession = RenderingSession.getNewInstance();
renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.SHOW_IMAGES_IN_HTML, false);
BrowserContent browserContent = renderingSession.getBrowserContent(connection, null, null);
Field field = browserContent.getDisplayableContent();
Regards,
-Kelum-