🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16070

ByteArray problem

#16070
From: Zellig
Date: Fri, 02 Apr 1999 00:00
46 lines
1591 bytes
I'm trying to put somes ByteArray into a bigger one. The big one will be the
param of a new DatagramPacket.

When it comes into the bMessage[300] it give me an OutOfBoundArray
Exception.

it's never crashing to same "i" value might be 75 or 84, etc...

i'm a bit lost with this basic problem

S.O.S

Z


public void publish(String name,String phone,String email,String message){
     byte buf[] = new byte[373];
     byte bName[] = new byte[25];
     byte bPhone[] = new byte[14];
     byte bEmail[] = new byte[30];
     byte bMessage[] = new byte[300];
     byte REQUEST[] = {'a','d','p','u','b'};
     int  i;

     bName = name.getBytes();
     bPhone = phone.getBytes();
     bEmail = email.getBytes();
     bMessage = message.getBytes();

     for(i=0;i<5;i++){
        buf[i] = REQUEST[i];
     }
     for(i=0;i<25;i++){
        buf[i+5] = bName[i];
     }
     for(i=0;i<30;i++){
        buf[i+30] = bEmail[i];
     }
     for(i=0;i<300;i++){
        System.out.println(i); // the problem is here
        buf[i+60] = bMessage[i];
     }
     for(i=0;i<14;i++){
        buf[i+360] = bPhone[i];
     }
  }
Technical Details
Message-ID: <7e2ifl$gsr5@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,769768ed403c57dd,start
X-Google-Attributes: gidf74b3,public
From: "Zellig" <greg@abacom.com>
Subject: ByteArray problem
Date: 1999/04/02
Message-ID: <7e2ifl$gsr5@forums.borland.com>
X-Deja-AN: 461946658
Organization: Another Netscape Collabra Server User
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Newsgroups: borland.public.jbuilder.java.language