You would have to read the first line and test if the first column matches the column header you expect. Since your code inserts the header, I'm assuming it knows what the header should look like. You can use this same variable in your header check. Something like:
String HEADER = "column1,column2,column3";
String COLUMN1 = HEADER.substring(0,HEADER.indexOf(",")+1); //Or just set it to "column1", but that would be violating the DRY principle!
//...Get line1, column1 from the file you are reading
if(!line1Column1.equals(COLUMN1))
{
out.write(HEADER);
}
// Print rows of data...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…