I have been getting this broken pipe Exception. As far as I understood this exception occurs when there is connection closed suddenly. I have attached the code below. Can you please tell where I am going wrong. Thanks.
remaingBarcode = gdbAutomationService.getGdbBarcodes(); //returning list of barcodes
StringBuffer barcodes = new StringBuffer();
barcodes.append("Barcode").append("\n");
for(int i = 0; i < remaingBarcode.size(); i++) {
barcodes.append(remaingBarcode.get(i));
barcodes.append("\n");
}
response.setContentType("text/csv");
response.addHeader("Content-Disposition", "attachment; filename = BarcodeDetails.csv");
OutputStream outputStream = null;
try {
outputStream = response.getOutputStream();
outputStream.write(barcodes.toString().getBytes());
} catch(IOException e) {
e.printStackTrace();
} finally {
System.out.println("In finally");
outputStream.flush();
outputStream.close();
}