• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sequential read w/ update to status flag  RSS feed

 
Larry Terry
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A long time Cobol programmer trying his luck at Java! Reading a sequential flat file (which is working) but now I need to add code to update the status flag (setting it to ‘Y’ position(7,1)) before I close the file and not sure how without defining the fields.

I’m sure this is extremely simple but just not seeing it – any suggestions?

Thanks in advance,
Larry

 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally, to change a file you need to read the whole file contents into memory, make the changes and then write the whole contents back to the file.
If the file is too large to hold the whole of it in memory, then you could read the contents of the file line by line and write each line out to a new temporary file, making any changes you need to a line before you write it out. You then delete the old file and rename the temporary file.

I notice you are using a ZFile object to open the file. I assume that is this class and so is specific to reading files on z/OS machines, but the suggestions above should still work for it.
 
Larry Terry
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Joanne!!

Received some additional information that has changed the scope of the project and forcing me to rethink my approach to this issue. Thanks for response, will keep that in mind for the future and yes, using Mainframe files!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!