So basically I have a list of java objects that need to be written into a text file with a specific format.
eg.
class car
{
String license;
String color;
String model;
String numOfSeats;
}
and this has to be written into a text file where the format of each line is
license--color-----model-------numOfSeats------
The license
must occupy 10 bytes, even if the length of the actual string is less.
The color
must occupy 10 bytes, and the model
must occupy 12 bytes etc.
So I want to create a template in such a way that I can just plug in the variables, and they occupy the required number of bytes (i.e. padded with spaces if shorter, truncated if longer)
So in the future, if the template changes, I don't need to make any code changes. I would just need to change the template.
I have been exploring JEXL but I am not sure how to achieve this with it.