Hi All,
I'm creating a java program that creates a file and fills it with data in string form with each field in the record limited to a specific length.
What I think I need to do is to create a class that has a string for the data field and a length specifying the length of the string. And then somehow restrict it so that the string never exceeds this length, either by bailing, padding with whitespace (if the data input is less that the length) or truncating the end so the data fits.
My first question is if there is already a basic class that will do this, or should I just roll my own.
My second question is if I do roll my own how do I make sure when the class is constructed that the initial value of the internal String is less than the length specified, Ive read elsewhere that a constructor should return a value, but is it valid for a constructor to raise an exception?
Thanks for any help.