Convert Byte Array into String

In the OTN forums, someone recently asked how to convert a byte array into a String. Assuming the byte array contains characters, not binary data, you can convert a binary array into a string by using the Java String byte array constructor. Here is a short example:

REM"syntax-COMMENT2"> **"syntax-COMMENT2"> Create"syntax-COMMENT2"> an"syntax-COMMENT2"> array"syntax-COMMENT2"> of"syntax-COMMENT2"> bytes"syntax-COMMENT2"> for"syntax-COMMENT2"> testing"syntax-COMMENT2"> purposes"syntax-COMMENT2">;
Local "syntax-KEYWORD3">JavaObject &input "syntax-OPERATOR">= "syntax-KEYWORD2">CreateJavaObject("syntax-LITERAL1">""syntax-LITERAL1">java.lang.String"syntax-LITERAL1">", ""syntax-LITERAL1">A "syntax-LITERAL1">test "syntax-LITERAL1">string.");
Local "syntax-KEYWORD3">JavaObject &bytes "syntax-OPERATOR">= &input.getBytes();

REM"syntax-COMMENT2"> Convert"syntax-COMMENT2"> the"syntax-COMMENT2"> bytes"syntax-COMMENT2"> back"syntax-COMMENT2"> into"syntax-COMMENT2"> a"syntax-COMMENT2"> String"syntax-COMMENT2">;
Local "syntax-KEYWORD3">JavaObject &output "syntax-OPERATOR">= "syntax-KEYWORD2">CreateJavaObject("syntax-LITERAL1">""syntax-LITERAL1">java.lang.String"syntax-LITERAL1">", &bytes);

MessageBox("syntax-DIGIT">0, ""syntax-LITERAL1">", 0, "syntax-DIGIT">0, &output.toString());