developerinlondon
Programmer
I need a way to check if the first 3 characters of a string equals something:
eg
basically I need to manually check if the data i am reading is UTF-16, if it is then convert it from utf-16 format, otherwise use standard method.
any thoughts on how I could do this?
thanks in advance.
eg
Code:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int i = -1;
while (true) {
i = rd.read(buffer, 0, buffer.length);
if (i == -1) break;
baos.write(buffer, 0, i);
}
/*
if baos.toByteArray() begins with '\xFF\xFE\x3C' then
*/
xml_in = new String(baos.toByteArray(), "utf-16");
/*
else
*/
xml_in = new String(baos.toByteArray());
baos.close();
any thoughts on how I could do this?
thanks in advance.