public boolean closeIfAllContentWritten(long written) throws IOException { if (_contentLength >= 0 && written >= _contentLength) { switch (_outputType) { case WRITER: _writer.close(); break; case STREAM: getOutputStream().close(); } return true; } return false; }