Writing byte to a particular location in a file header
john kalaigian
Greenhorn
Joined: Nov 20, 2001
Posts: 15
posted
0
Ok I have a file with a header which I've read and know the exact location of the particular element that I want to read. What I want to do now is overwrite that particular element of the file with a byte representation of a String. How do i do this, and also without creating a new file, cause I'm using a FileInStream->BufferedInStream->DataInStream to do the reading and I don't want to create a brand new FileOutStream->BufferedOutStream->DataOutStream to do the writing. I want to just overwrite particular elements in the file header. Thanks, John
Ok here's my code if it would help out. I just wanna have you take a look to see if it really has to be done with RandomAccessFile
What I wanna do is not go into a particular header line say (0020,0010) which is group 0020, and overwrite element 0010, so somewhere in my case statement I will have:
Now here's the problem. I don't know where to start writing this data because up in getNextDataElement(DataInStream) I read from the DataInStream starting at 0 and going up to the length provided in the header. Now that I'm sitting in the retrieveData method I'm just parsing through the groups and reading the bytes provided in my byte buffer. Where and how do I write my new String into the file without creating a new file - just modifying the bytes specified in the group. Hope this is a little more comprehensive. John
john kalaigian
Greenhorn
Joined: Nov 20, 2001
Posts: 15
posted
0
Sorry about the above. I wrote:
What I wanna do is not go into a...
It should be
What I wanna do is go into a...
John
subject: Writing byte to a particular location in a file header