Re: Help - JNI and JMS - data conversion problems

From: Roedy Green (roedy_at_seewebsite.com)
Date: 10/27/03


Date: Mon, 27 Oct 2003 20:05:07 GMT

On Mon, 27 Oct 2003 18:53:53 GMT, "gailw" <gailw@worldnet.att.net>
wrote or quoted :

>If I embed some binary bytes (e.g. 0x00,0x01,0x02,0x03,0x04) in the middle
>of the buffer, the data goes all the way thru the send side to the server
>(currently using Sun's j2ee for testing).

You are passing a raw byte array. What it could be is a
DataOutputStream in a raw byte array.

to create such a beast see http://mindprod.com/fileio.html

You can read it with a DataInputStream.

Note when you do this your Strings will be counted UTF-8 format.
You could write them an char[] if you wanted the simplicity of 16-bit
chars.

Trying to encode binary data in Strings is asking for trouble unless
you use something very vanilla like base64.

see http://mindprod.com/jgloss/base64.html

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming. 
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.


Relevant Pages

  • Re: files and directories into an array of arrays
    ... can use an array of arrays of char: ... out that you in fact need 43 strings, ... struct filename * next; ... size array in struct filename is wasteful and that you can easily replace it ...
    (comp.lang.c)
  • Re: two dimensional arrays passed to functions
    ... > array and then send it down as a single dimmensional array. ... x is an array of char pointers. ... to a pointer to the first element of this array, ... need to copy the strings and not just assign pointers to them). ...
    (comp.lang.c)
  • Re: a string, a string array and character array
    ... which defined its "char" to be in the range -128 to 127. ... with strings, like sorting. ... A character array is an array of character type; ...
    (comp.soft-sys.matlab)
  • Re: Returning an array of strings in C
    ... fucntion and return char** type. ... you can't return an array from a C function. ... Now for strings it gets a bit more ... take when allocating memory dynamically. ...
    (comp.lang.c)
  • Re: Help - JNI and JMS - data conversion problems
    ... The reason for embedding the binary data in text data was purely to test ... there are occasions where it must place "raw" data on the Queues. ... and/or char[] data. ... > Note when you do this your Strings will be counted UTF-8 format. ...
    (comp.lang.java.programmer)