Reputation: 13
I am working on writing of data into CSV file using Java. How can I give left alignment to each column in CSV File?
public class WriteToFileCsv
{
public static void main(String[] args) throws IOException
{
FileWriter fw = new FileWriter("WriteTest.csv");
PrintWriter out = new PrintWriter(fw);
out.print("This");
out.print(",");
out.print("is");
out.print(",");
out.print("It's");
out.print(",");
out.print("really");
out.print(",");
out.flush();
out.close();
fw.close();
}
}
Upvotes: 1
Views: 4221
Reputation: 44854
To have alignment in you csv file you need to create an excel file. Try Apache POI
Upvotes: 0
Reputation: 7044
You are referring to Fixed-Length data format. CSV is not meant to have alignment.
Upvotes: 1