• Post Reply Bookmark Topic Watch Topic
  • New Topic

Record length desription

 
Patrick Muls
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've to provide a file for another company's application. That requires that the file consists of records of 80 positions long, and restricts the acceptable character values to those between hexa-values 20 and 5D. In my first test I used \n characters to divide my file into records. But their application rejects those \n characters. So I'm looking for another way to define an 80-position file, without using the \n. I remember that on mainframes one could give a file descriptor saying that the record length was such and the blocksize was so. Is this also possible in any of the java IO classes? I looked at the FileDescriptor class, but that doen't seem to describe anything
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you're writing files to be read by a non-Java app. When they talk fixed length records with no CR/LF they'll just read that many bytes and call it a record. If you look at it with a text editor you'll just see a stream of bytes. You need to write 80 bytes for every record. Maybe create a String with 80 spaces in it and try:
myOut.write( theRecordString );
myOut.write( eightyBlanks.substring( theRecord.length() );
I could be off by one there. Be careful to test with 0 and 80 byte records.
How about the record itself? Is it made up of fixed length fields? I've done lots of clients to COBOL servers and for that you would have to pad each field right or left with blanks or zeros to the right length.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!