I have a system where I do some search in the database and store everything in Array
, however I have to assemble a layout with this data so they can be printed as labels in a dot matrix printer.
The part of the lines I have already formatted, but I do not know how to make the next record in the list instead of going to the next line turn a column.
I need to leave it this way:
WhatIcangetnowisthis:
Inthiscasemyqueryreturnedonlytworesults,therightthingwouldbetoputthatsecondrowinacolumnasinthefirstimage.
Thisismyclassthatgeneratestxt
:
publicstaticvoidgerarTxt(List<Contrato>lista){try{FileWriterarq=newFileWriter("C:\etiqueta.txt");
PrintWriter gravarArq = new PrintWriter(arq);
for (Contrato item : lista) {
gravarArq.print(item.getContrato());
gravarArq.print("\r\n");
gravarArq.print(item.getContratante());
gravarArq.print("\r\n");
gravarArq.print(item.getRua().trim()+", "+item.getNumero());
gravarArq.print("\r\n");
gravarArq.print(item.getBairro());
gravarArq.print("\r\n");
gravarArq.print(item.getCep() + " "+item.getCidade()+ " "+StringUtils.leftPad(item.getUf(), 22));
gravarArq.print("\r\n");
gravarArq.print(".");
gravarArq.print("\r\n");
}
arq.close();
} catch (IOException e) {
e.printStackTrace();
}
}
How can I turn these rows into columns?
Update
Sample project in GitHub: link