Closes this stream. @throws IOException if an error occurs attempting to close this stream.
()
| 152 | * if an error occurs attempting to close this stream. |
| 153 | */ |
| 154 | @Override |
| 155 | public void close() throws IOException { |
| 156 | if (fd == null) { |
| 157 | // if fd is null, then the underlying file is not opened, so nothing |
| 158 | // to close |
| 159 | return; |
| 160 | } |
| 161 | // if (channel != null) { |
| 162 | // synchronized (channel) { |
| 163 | // if (channel.isOpen()) { |
| 164 | // channel.close(); |
| 165 | // } |
| 166 | // } |
| 167 | // } |
| 168 | synchronized (this) { |
| 169 | if (fd.descriptor >= 0) { |
| 170 | fileSystem.close(fd.descriptor); |
| 171 | fd.descriptor = -1; |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * Ensures that all resources for this stream are released when it is about |