I am trying to add lines or text between columns ONLY before it prints out so the text file is has each column on one line of the text file.
The table prints out rows and than spaces, but I want the columns to have added text only when writing also have a added line.
Example:
<bufferedline>
(Name: /<BufferedText>)
TableCellName
(Name: /<BufferedText>)
<bufferedline>
(Number: /<BufferedText>)
TableCellColumnNumber
(Number: /<BufferedText>)
<bufferedline>
etc.... (Total of 7)
The code I use prints out row by row and splits with ______
but I want to modify this code to be able to print out text before and after certain column cells.
Appreciate any help. Super new I feel like it should be easy but can't figure it out, I understand if this is confusing, it is the best way I can describe how I need help.
___________Code I Use___________________________
btnWrite.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
File file = new File("Text.txt");
if(!file.exists()){
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
for(int i = 0; i < table.getRowCount(); i++){
for(int j = 0; j < table.getColumnCount(); j++){
bw.write(table.getModel().getValueAt(i, j)+" ");
}
bw.write("\n_________\n");
}
bw.close();
fw.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
});
}
____________________________________________
No error codes in this code, but I want to modify to have bw write things before and after j(Column) + Lines to split information on a text in a format I need.