Closes this writer. This implementation flushes the buffer as well as the target stream. The target stream is then closed and the resources for the buffer and converter are released. Only the first invocation of this method has any effect. Subsequent calls do nothing. @throws IOException
()
| 144 | * if an error occurs while closing this writer. |
| 145 | */ |
| 146 | @Override |
| 147 | public void close() throws IOException { |
| 148 | synchronized (lock) { |
| 149 | if (encoder != null) { |
| 150 | if (encoderFlush) { |
| 151 | CoderResult result = encoder.flush(bytes); |
| 152 | while (!result.isUnderflow()) { |
| 153 | if (result.isOverflow()) { |
| 154 | flush(); |
| 155 | result = encoder.flush(bytes); |
| 156 | } else { |
| 157 | result.throwException(); |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | flush(); |
| 163 | out.flush(); |
| 164 | out.close(); |
| 165 | encoder = null; |
| 166 | bytes = null; |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Flushes this writer. This implementation ensures that all buffered bytes |
nothing calls this directly
no test coverage detected