MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / saveAs

Method saveAs

src/main/java/org/htmlunit/html/HtmlImage.java:788–796  ·  view source on GitHub ↗

Saves this image as the specified file. @param file the file to save to @throws IOException if an IO error occurs

(final File file)

Source from the content-addressed store, hash-verified

786 * @throws IOException if an IO error occurs
787 */
788 public void saveAs(final File file) throws IOException {
789 downloadImageIfNeeded();
790 if (null != imageWebResponse_) {
791 try (OutputStream fos = Files.newOutputStream(file.toPath());
792 InputStream inputStream = imageWebResponse_.getContentAsStream()) {
793 IOUtils.copy(inputStream, fos);
794 }
795 }
796 }
797
798 /**
799 * {@inheritDoc}

Callers 1

Calls 3

downloadImageIfNeededMethod · 0.95
getContentAsStreamMethod · 0.45
copyMethod · 0.45

Tested by 1