@Override
    public void emit(String path, InputStream inputStream, Metadata userMetadata, ParseContext parseContext) throws IOException, TikaEmitterException {
        Path target = basePath.resolve(path);

        if (!Files.isDirectory(target.getParent())) {
            Files.createDirectories(target.getParent());
        }
        if (onExists == ON_EXISTS.REPLACE) {
            Files.copy(inputStream, target, StandardCopyOption.REPLACE_EXISTING);
        } else if (onExists == ON_EXISTS.EXCEPTION) {
            Files.copy(inputStream, target);
        } else if (onExists == ON_EXISTS.SKIP) {
            if (!Files.isRegularFile(target)) {
                try {
                    Files.copy(inputStream, target);
                } catch (FileAlreadyExistsException e) {
                    //swallow
                }
            }
        }
    }
What to do if the target file already exists.  NOTE: if more than one
thread is trying write to the same file and {@link ON_EXISTS#REPLACE} is chosen,
you still might get a {@link FileAlreadyExistsException}.

@param onExists
tika-pipes/tika-emitters/tika-emitter-fs/src/main/java/org/apache/tika/pipes/emitter/fs/FileSystemEmitter.java