Local html imgae referenc is not working
Please Login to Remove!
HI,
I my blackberry native application i am calling local html file (in part of my package), also i have image reference in that local html file. I am able to show the html file in web view but its not rendering the image.
I have image and html file under SRC folder.
I am using beloe code for rendering the local html file in webview
try {
// Open the connection and the input stream. Select your own
// URL.
//HttpConnection connection = (HttpConnection) Connector.open("http://www.blackberry.com:80");
//InputStream input = connection.openInputStream();
InputStream input = getClass().getResourceAsStream(weburl);
DataBuffer buffer = new DataBuffer();
byte[] temp = new byte[1024];
// Read in the web page to the DataBuffer.
for (;;) {
int bytesRead = input.read(temp);
if (bytesRead == -1) {
break;
}
buffer.write(temp, 0, bytesRead);
}
input.close();
//connection.close();
// Create an output stream that will be used by the Base64 code.
ByteArrayOutputStream output = new ByteArrayOutputStream();
Base64OutputStream boutput = new Base64OutputStream(output);
// Write out the special sequence which indicates to the browser
// that it should treat this as HTML data in base64 format.
output.write("data:text/html;base64,".getBytes());
boutput.write(buffer.getArray());
boutput.flush();
boutput.close();
output.flush();
output.close(); // Invoke the browser with the encoded HTML
// content.
BrowserSession bSession = Browser.getDefaultSession();
bSession.displayPage(output.toString());
} catch (IOException e) {
System.out.println("IOException: " + e);
}
Please help me out on this.
Thanks in advance.
|