我得到了这个破管道异常。据我所知,当连接突然关闭时会发生此异常。我已附上以下代码。你能告诉我哪里出错了吗? 感谢。
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();
}