Hello If I have my string in a byte[] byte[] myString = "testString"; how do I print it out? I have tried myString.toString(), however that just gives me the pointer to the byte[] on the heap. How does this then work with the locale? tia.
What is your encoding? Try using one of String's constructors:
String(byte[] bytes) //platform's default charset String(byte[] bytes, String charsetName) [ December 29, 2005: Message edited by: Jeff Albrechtsen ]
There is no emoticon for what I am feeling!
Chris Pat
Ranch Hand
Joined: Aug 27, 2005
Posts: 156
posted
0
Hi Jeff Thanks. However it still in not working. I have created a list with below and I still get the same results
... byte[] string0 = "ListString1".getBytes(); byte[] string1 = "ListString2".getBytes(); byte[] string2 = "ListString3".getBytes(); List list = new ArrayList(); list.add(string0); list.add(string1); list.add(string2); ...
... boolean firstTime = true; for (int i = 0; i < len; i++) { if (firstTime) { firstTime = false; } else { buffer1.append(','); } byte[] element = (byte[]) value_.get(i); buffer.append("A "); System.out.println("tempChar= "+new String(element.toString())); buffer.append(new String(element.toString())); } buffer1.append('}'); return buffer1.toString(); ...
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
Maybe it's time to step back. That code you posted was really torturing strings! What are you trying to do, what is your goal? What do you need byte[]'s? What aren't you working solely with Strings?
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.