a question about socket and arrays !
wutongjoe_at_hotmail.com
Date: 04/22/04
- Next message: Rahul: "GregorianCalendar"
- Previous message: Tony Morris: "Re: delete a char from string ?"
- Next in thread: Daniel Sjöblom: "Re: a question about socket and arrays !"
- Reply: Daniel Sjöblom: "Re: a question about socket and arrays !"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 22 Apr 2004 22:47:48 +1200
hi, I just began with studying java and have a question about reading
bytes from file(fileA).Every time I make it read into a byte array with
size 256.I used a while loop to see whether the next byte is a -1,if it
is then stop .
int c,j=0;
mByteData=new byte[256];
while ((c=mByteSource.read())!= -1&&j<256){
mByteData[j]=(byte)c;
j++;
}
Q1: what is the second array like if the file size is 270kb ?(first 14
are bytes from file and rest are null ? or empty ? or zero ?)
Q2 : if I copy the array byte after byte using a for loop like
byte[] b2=new byte[256];
for(int i=0;i<256;i++){
b2[i]=b1[i];
}
how can I write bytes to fileB and make fileA and fileB identical?
(MD5 sum)
because every time I found from 14th byte all the rest bytes
are all zeros ,there is no -1 and I do not know where to stop if I
want to write them to fileB.
---------------------------------------------------------------------------
Question about socket:
I am going to send packets to the server using lots of threads(one
packet per thread) and what should the server do? does it listen with
same amount of socket threads and then use them to send back the
acknowledgments? or just one socket listening on all coming packets ?
(after received,I will write them to a file,so it is like a uploading app)
Am I clear enough ?
- Next message: Rahul: "GregorianCalendar"
- Previous message: Tony Morris: "Re: delete a char from string ?"
- Next in thread: Daniel Sjöblom: "Re: a question about socket and arrays !"
- Reply: Daniel Sjöblom: "Re: a question about socket and arrays !"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|