문제

I faced Broken Pipe Exception while read file from my folder directory. Please go through my following code...

FileInputStream inputStream = new FileInputStream(file);
ServletOutputStream outputStream = response.getOutputStream();        
IOUtils.copy(inputStream, outputStream);
IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(outputStream);

Broken Pipe occurred while copying inputStream and outputStream in IOUtils.copy(inputStream, outputStream);

How can i solve Broken Pipe? can i use PipedInputStream? Is this proper way to handle this exception.

도움이 되었습니까?

해결책

It's caused by writing to a connection that has already been closed by the peer.

In this case, the peer is either a Web browser or a Web client application.

If the former, there is nothing you can do. The user can cancel the download any time, and that will cause a broken pipe exception.

In the second case, the client application may be at fault.

In either case, there is nothing you can do about it in the server code, except log it and forget about it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top