Hi everybody
I have a question is it possible to send a byte[] to the src attribute in a <img> HTML tag. What i would like to gain is a way of reading an img file from the jar in a custom tag which is no problem. Problems start when i want to send a byte[] which I have read from the InputStream to the StringBuffer which contains the HTML code.
byte[] dataByte = null;
String charEncoding = "UTF-8";
InputStream in = imageURL.openStream(); //InputStream to the img file inside a jar
StringBuffer buffer = new StringBuffer();
StringBuffer sb = new StringBuffer();
String imgData = "";
int data;
while((data = in.read()) != -1)
{
buffer.append(new Integer(data).toString(), charEncoding);
}
imgData = buffer.toString();
dataByte = imgData.getBytes();
The problem starts in this line, i think i need some encoding to do this.
sb.append("<img src=\""+dataByte.toString()+"\">");
thx in advance