I can't resolv a problem, please help me...

Hi,
The problem is in this code, I try create a Text File with bytearray, but the result doesn't expected :
The problem is on the part of sale.write(body).
I don't received the text correct in the file. The description of the problem is before the code. Please help me, with that problem.
Code:
javax.jms.BytesMessage bytesMessage = (javax.jms.BytesMessage) aMessage;
try
while (true)
int numBytesRead = bytesMessage.readBytes(buffer);
if (numBytesRead == -1)
break;
byte[] tmp = new byte[body.length + numBytesRead];
System.arraycopy(body,0,tmp,0,body.length);
System.arraycopy(buffer,0,tmp,body.length,numBytesRead);
body = tmp;
try
java.io.File file = new java.io.File("paso0409.txt");
java.io.FileOutputStream outputStream = new java.io.FileOutputStream(file);
java.io.DataOutputStream sale = new java.io.DataOutputStream(outputStream);
for(int i = 0; i < body; i++){
sale.write(body);
catch(java.io.IOException jaio)
catch (javax.jms.JMSException jsme)
The file, show me the next text:
qS ��ISO8859-1 � ������EDI_DC40
but the correct text is only ("EDI_DC40"), blank spaces and other text.
How I do, to see only text and not see bytes character ??
Thank's to help me !!
Hervey P.

Is the line:
for(int i = 0; i < body; i++){
really supposed to be:
for(int i = 0; i < body.length; i++){
Assuming that's right, one problem I see is the method DataOutputStream.write(byte[] bytes) writes the whole array, but you have a loop that writes the same data body.length times.
On the other hand, it you are going to write a byte array to a file, then you can use the FileOutputStream directly, without using a DataOutputStream.
Your post does not show how the byte array body gets filled. My guess is that's where your problem lies. You might try putting a line in somewhere to display what the contents of the body array is.
System.out.println(new String(body));
should show you the character interpretation of the array of bytes.

Similar Messages

Maybe you are looking for

  • How can i delete my itunes account as i think im being hacked, almost every day itunes are taking accessive amounts of money from my account!

    Dear Apple support, how can i delete my itunes account as i think im being hacked!! over the past few months a lot of money seems to be taken from my account ranging from as little as £1 to £60... i cant take any more. Can i delete the account? Can u

  • Ods is not consistent

    when i checked an ods i had created ,it showed a message:ods XXX is not consistent,i want to know what is it mean of this not consistent ?does it compare with something?if yes,what  does it compare with and how can i correct this mistake?

  • Alerts for certificate expiry?

    Hello everyone, I have a quick question: is there any way to get alerts for certificate expiry before a threshold number of days? If so, can the alert be for certificates that are required for the PI environment, SAP Portal or infrastructure ones tha

  • ThinkPad USB Keyboard Driver SK-8855

    The ThinkPad USB Keyboard SK-8855 is not listed in the driver matrix.  I can only find the one for the newer 55Y9003.  Help?  Does anybody know if the newer driver works with the older keyboard?

  • New Ipod freezing itunes.

    I just got an ipod 80gb classic. I already have a 5th generation 30gb on file in itunes. I'm trying to sync my new 80gig and itunes freezes up. As soon as i disconnect the ipod everything unfreezes. It's downloaded like 9 songs then stops. I also got