This discussion is archived
2 Replies Latest reply: Jan 7, 2008 3:59 PM by 807603 RSS

*very stupid* question about char[] to String.  But please help!!!

807603 Newbie
Currently Being Moderated
Hi! My problem is simple so I feel extremely stupid not being able to find out a solution by myself.
I'm parsing an XML file using SAX, and I need to generate a String from a char[].

If I print in the console the characters one by one, by
for (int i = start; i < start + length; i++) 
{
      System.out.print(ch);
}
I obtain 

[[Categoria:Statunitensi]]
[[Categoria:Sport negli Stati Uniti]]
[[Categoria:Sportivi per nazionalit´┐Ż|Statunitensi]]

but if I try to get the string I need, by
String tmp = new String();
for (int i = start; i < start + length; i++)
{
tmp += ch[i];
}
and then I try to print it, I obtain

[[Categoria:Statunitensi]]
[[Categoria:Sport negl
i Stati Uniti]]
[[Categoria:Sportivi per nazionalit´┐Ż|Statunitensi]]

I know that a StringReader is better, but it gives the same problem.  Tried with the String(char[]) constructor but the same. 

A virtual beer to anyone able to solve this... thank you!!!!

Francesco