protected final void write(Path outputFile) { try { Files.createDirectories(outputFile.normalize().getParent()); FileChannel channel = FileChannel.open(outputFile, StandardOpenOption.WRITE, StandardOpenOption.READ, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE); objectFile.write(channel); } catch (Exception ex) { throw shouldNotReachHere(ex); } resultingImageSize = (int) outputFile.toFile().length(); if (NativeImageOptions.PrintImageElementSizes.getValue()) { for (Element e : objectFile.getElements()) { System.out.printf("PrintImageElementSizes: size: %15d name: %s\n", e.getMemSize(objectFile.getDecisionsByElement()), e.getElementName()); } } }