byte[] problem

G

Geez

Hello all,

I created a descriptor which contains of two parts:
1: header: fixed length
2: field: variable length

The field part will contain a list of files. Now from 1 to 22 files i got no
problems.
But at 23 files i have problems sending the descriptor after i created it.

descriptor: (22 files)
- length byte[] header: 19
- length byte[] field: 479

descriptor: (23 files)
- length byte[] header: 19
- length byte[] field: 499

What can i have done wrong? Any advice?

Greetings

Geez
 
B

Boudewijn Dijkstra

Geez said:
Hello all,

I created a descriptor which contains of two parts:
1: header: fixed length
2: field: variable length

The field part will contain a list of files. Now from 1 to 22 files i got no
problems.
But at 23 files i have problems sending the descriptor after i created it.

descriptor: (22 files)
- length byte[] header: 19
- length byte[] field: 479

19 + 479 < 512
descriptor: (23 files)
- length byte[] header: 19
- length byte[] field: 499

19 + 499 > 512
What can i have done wrong? Any advice?

Flush the stream.
 
G

Geez

Hallo Boudewijn,

Thanks for your reply, but i don't understand it well in fact.
What's so special about 512?

Greetings

Geez
 
B

Boudewijn Dijkstra

Geez said:
Hallo Boudewijn,

Thanks for your reply, but i don't understand it well in fact.
What's so special about 512?

The default buffer size for a BufferedInputStream or a BufferedOutputStream is
512 bytes. A common mistake is forgetting that buffered streams don't
transfer their data immediately, but only in chunks of the buffer size or when
flushing it programmatically.
 
C

christopher

You didn't really ask what's so special about 512, did you? Gee,
that's like not knowing phones used to have rotary dials, hence "dial a
phone". I'll bet you weren't alive when we landed on the moon, were
you . . .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top