wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes Fixed size file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Fixed size file" Watch "Fixed size file" New topic
Author

Fixed size file

Angela D'souza
Ranch Hand

Joined: Jan 16, 2002
Posts: 469
I want to create file which will contains some record details. Each record must be 16 byte fixed size. How can I create 16 byte fixed size file for each record?
Thanks,
Angela
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi Angela
i am not clear about your question. initially u say that u wanted a file where there are multiple records and each record is of 16 byte size....but in the end sentence you say that you want "16 byte fixed size file for each record"...
so i assume that you want a file,
1. where there are number of records
2. you don't know the number of records
3. each record is 16 bytes
4. you want to create a file that can constraint the record size to be 16 bytes
well, this is not possible it seems. if u were able to know the number of records say N then you can do math 16*N bytes file size. but still you can't create a file that puts restriction of 16*N bytes capacity.
what you can do is,
you can create byte[] of 16 bytes for each record and then create array (Object array) of thoes records and then dump each of them in the file.
i don't think that Java can control file size factor as its OS dependent.
regards
maulin.
Angela D'souza
Ranch Hand

Joined: Jan 16, 2002
Posts: 469
Originally posted by Maulin Vasavada:
hi Angela
so i assume that you want a file,
1. where there are number of records
2. you don't know the number of records
3. each record is 16 bytes
4. you want to create a file that can constraint the record size to be 16 bytes
regards
maulin.

Sorry for not clear. Yes ur right.
I want a file:
(1) Where I want to add multiple records(I don't the total number of records).
(2) Each record (i add to file) has to be fixed size-16 bytes
Thanks
Angela
Angela D'souza
Ranch Hand

Joined: Jan 16, 2002
Posts: 469
Do you have any other good suggestions???
Thanks,
Angela
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi Angela
i don't think we have a way to do this. we have to put wrapper like i suggested that will restrict input in the way you want so you don't run into file size violation ever.
thanks
maulin.
 
Don't get me started about those stupid light bulbs.
 
subject: Fixed size file