I've looked for comparison in speed between the StringReader and a simple for loop, and have been unable to come up with anything useful. What I'm interested in is using jaxb to convert a string to a jaxb Object. The answer I found ( Use JAXB to create Object from XML String ) indicated I need to wrap my string in a StringReader, which makes sense, however it would require some work to put it together properly. (I'm using a custom class to marshal and unmarshal objects, which I would have to check out, modify, submit, then re-import into my project. This is a big time sink.) I found that I can do the same thing by simply converting my string into a byte[] and then using existing methods to get the object I need like so:
String responseAsString = " <?xml ver....";
byte[] myResponse = new byte[responseAsString.length()];
for(int i = 0; i < responseAsString.length(); i++){
myResponse[i]=(byte)responseAsString.charAt(i);
}
So my question is this: If my responseAsString is around 200,000 characters long is this method going to be significantly slower than using StringReader to get my jaxb object?