public void close()

in commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultFileContent.java [311:362]


    public void close() throws FileSystemException {
        FileSystemException caught = null;
        try {
            final FileContentThreadData threadData = getFileContentThreadData();

            // Close the input stream
            while (threadData.hasInputStream()) {
                final InputStream inputStream = threadData.removeInputStream(0);
                try {
                    if (inputStream instanceof FileContentInputStream) {
                        ((FileContentInputStream) inputStream).close();
                    } else if (inputStream instanceof RawFileContentInputStream) {
                        ((RawFileContentInputStream) inputStream).close();
                    } else {
                       caught = new FileSystemException("Unsupported InputStream type: " + inputStream);
                    }
                } catch (final FileSystemException ex) {
                    caught = ex;

                }
            }

            // Close the randomAccess stream
            while (threadData.hasRandomAccessContent()) {
                final FileRandomAccessContent randomAccessContent = (FileRandomAccessContent) threadData
                        .removeRandomAccessContent(0);
                try {
                    randomAccessContent.close();
                } catch (final FileSystemException ex) {
                    caught = ex;
                }
            }

            // Close the output stream
            final FileContentOutputStream outputStream = threadData.getOutputStream();
            if (outputStream != null) {
                threadData.setOutputStream(null);
                try {
                    outputStream.close();
                } catch (final FileSystemException ex) {
                    caught = ex;
                }
            }
        } finally {
            threadLocal.remove();
        }

        // throw last error (out >> rac >> input) after all closes have been tried
        if (caught != null) {
            throw caught;
        }
    }