public static void streamToFile(final InputStream inputStream, final Path file) {
        try {
            if (Files.isRegularFile(file)) {
                FileUtil.deleteFile(file);
            }
            Files.createDirectories(file.getParent());

            try (final OutputStream fos = new BufferedOutputStream(Files.newOutputStream(file))) {
                streamToStream(inputStream, fos);
            }
        } catch (final IOException ioEx) {
            // Wrap it
            throw new UncheckedIOException(ioEx);
        }
    }
Take a stream to a file.

@param inputStream    to read and close
@param outputFileName to (over)write and close
stroom-util/src/main/java/stroom/util/io/StreamUtil.java