Skip to Content
0
Former Member
May 22, 2005 at 11:21 AM

Reading mixed language content from a resource

13 Views

Hello all,

I have a resource 'res' and I want to read its contents. I've written the following code to do this.

StringBuffer sb = new StringBuffer();
IContent con = res.getUnfilteredContent();
int len = (int)con.getContentLength();// It's a small resource
byte[] bArray = new byte[len];
InputStream is = con.getInputStream();
is.read(bArray, 0, len);
is.close();
for(int i=0;i<bArray.length;i++)
  sb.append((char)(bArray<i> & 0xFF));
return sb.toString();

This reads English fine but my resource has English and another language which comes back as garbage.

It's an XML Form that I'm reading and I'm trying to grab a specific element, an image link. The path is mixed language.

Any ideas what I can do to solve this?

Regards,

Patrick.