Captures the whole screen and saves it as png to the specified file. The file must have the
extension {@code png}. Any necessary but non-existent parent directories of the specified
file are created.

@param file
the file to save the screenshot to
331494
public static void captureScreen(final File file) {
		Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
		captureScreenRect(file, rectangle);
	}
1029488
public void createFileUploadHandler(File file) {

		final String uuid = file.getProperty(GraphObject.id);

		uploads.put(uuid, new FileUploadHandler(file));

	}
505045
public void registerFileResource(final String file) {
        try {
            _resourceMap.put(file, new File(file).toURI().toURL());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
597684
@PreAuthorize("isAuthenticated()")
    public E saveImage(MultipartFile file, boolean createThumbnail, Integer thumbnailTargetSize)
        throws Exception {

        InputStream is = null;
        ByteArrayInputStream bais = null;
        E imageToPersist = null;

        try {
            is = file.getInputStream();
            byte[] imageByteArray = IOUtils.toByteArray(is);

            // create a new instance (generic)
            imageToPersist = getEntityClass().newInstance();

            // create a thumbnail if requested
            if (createThumbnail) {
                byte[] thumbnail = scaleImage(
                    imageByteArray,
                    FilenameUtils.getExtension(file.getOriginalFilename()),
                    thumbnailTargetSize);
                imageToPersist.setThumbnail(thumbnail);
            }

            // set binary image data
            imageToPersist.setFile(imageByteArray);

            // detect dimensions
            bais = new ByteArrayInputStream(imageByteArray);

            BufferedImage bimg = ImageIO.read(bais);

            // set basic image properties
            imageToPersist.setWidth(bimg.getWidth());
            imageToPersist.setHeight(bimg.getHeight());
            imageToPersist.setFileType(file.getContentType());
            imageToPersist.setFileName(file.getOriginalFilename());

            // persist the image
            dao.saveOrUpdate(imageToPersist);

        } catch (Exception e) {
            throw new Exception("Could not create the Image in DB: "
                + e.getMessage());
        } finally {
            IOUtils.closeQuietly(is);
            IOUtils.closeQuietly(bais);
        }

        return imageToPersist;
    }
595036
public int writeGraphToFile(byte[] img, String file)
	{
		File to = new File(file);
		return writeGraphToFile(img, to);
	}
512357
def screenshot(self, filename=None, scale=1.0, method=None):
        
        image = None
        method = method or self._screenshot_method
        if method == 'minicap':
            try:
                image = self._adb_minicap(scale)
            except Exception as e:
                logger.warn("use minicap failed, fallback to screencap. error detail: %s", e)
                self._screenshot_method = 'screencap'
                return self.screenshot(filename=filename, scale=scale)
        elif method == 'screencap':
            image = self._adb_screencap(scale)
        else:
            raise RuntimeError("No such method(%s)" % method)

        if filename:
            image.save(filename)
        return image
165766
public void saveAsJPEG(File file, int width, int height) throws IOException, TranscoderException {
    saveAsJPEG(file, width, height, DEFAULT_QUALITY);
  }
564806
public void loadTagMappingFile(String file) {
        if (file != null) {
            File f = new File(file);
            if (!f.exists()) {
                throw new IllegalArgumentException("tag mapping file parameter points to a file that does not exist");
            }
            if (f.isDirectory()) {
                throw new IllegalArgumentException("tag mapping file parameter points to a directory, must be a file");
            } else if (!f.canRead()) {
                throw new IllegalArgumentException(
                        "tag mapping file parameter points to a file we have no read permissions");
            }

            try {
                this.tagMapping = OSMTagMapping.getInstance(f.toURI().toURL());
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
            }
        } else {
            this.tagMapping = OSMTagMapping.getInstance();
        }
        this.tagMapping.setTagValues(this.tagValues);
    }
491306
def screenshot(filename, width=None, height=None):
    '''
    
    '''
    width = width or viewer.widget.width()
    height = height or viewer.widget.height()
    
    img = viewer.widget.toimage(width, height)
    img.save(filename)
751758
public static boolean isSnapshotFile(File file) {
    checkNotNull(file, "file cannot be null");
    String fileName = file.getName();

    // The file name should contain an extension separator.
    if (fileName.lastIndexOf(EXTENSION_SEPARATOR) == -1) {
      return false;
    }

    // The file name should end with the snapshot extension.
    if (!fileName.endsWith("." + EXTENSION)) {
      return false;
    }

    // Parse the file name parts.
    String[] parts = fileName.substring(0, fileName.lastIndexOf(EXTENSION_SEPARATOR)).split(String.valueOf(PART_SEPARATOR));

    // The total number of file name parts should be at least 2.
    if (parts.length < 2) {
      return false;
    }

    // The second part of the file name should be numeric.
    // Subtract from the number of parts to ensure PART_SEPARATOR can be used in snapshot names.
    if (!isNumeric(parts[parts.length - 1])) {
      return false;
    }

    // Otherwise, assume this is a snapshot file.
    return true;
  }
854828
private void saveScreenshotTo(final File file) throws IOException {
		byte[] bytes = null;
		try {
			bytes = ((TakesScreenshot) driver)
					.getScreenshotAs(OutputType.BYTES);
		} catch (ClassCastException e) {
			WebDriver augmentedDriver = new Augmenter().augment(driver);
			bytes = ((TakesScreenshot) augmentedDriver)
					.getScreenshotAs(OutputType.BYTES);
		}

		Files.write(bytes, file);
	}
284570
public void saveAs(final File file) throws IOException {
        try {
            final FileOutputStream out = new FileOutputStream(file);
            try {
                this.save(out);
            } finally {
                out.flush();
                out.close();
            }
        } catch (final FileNotFoundException e) {
            this.logger.log(Level.SEVERE, "Can't open " + file, e);
            throw new IOException(e);
        } catch (final NullPointerException e) {
            this.logger.log(Level.SEVERE, "No file", e);
            throw new IOException(e);
        }
    }
1114804
public void setFile(File file) {
		if(file != null) {
			this.file = file;
			
			// Replace the label by the file's name.
			this.setLabel(file.getName());
			
			// Change the icon, depending if the file is a folder or not.
			this.updateIcon();
		}
	}
16359
public void loadFile(File file)
   {
      InputStream is = null;

      try
      {
         is = new FileInputStream(file);
         POIFSFileSystem fs = new POIFSFileSystem(is);
         m_model.setFile(fs);
      }

      catch (IOException ex)
      {
         throw new RuntimeException(ex);
      }

      finally
      {
         StreamHelper.closeQuietly(is);
      }
   }
344064
public void save() {
		int resp = saveChooser.showSaveDialog(this);
		if (resp == JFileChooser.APPROVE_OPTION) {
			File file = saveChooser.getSelectedFile();
			String type = null;
			if (file.getName().endsWith(".png")) {
				type = "PNG";
			}
			if (file.getName().endsWith(".gif")) {
				type = "GIF";
			}
			if (file.getName().endsWith(".jpg")) {
				type = "JPG";
			}
			if (type == null) {
				file = new File(file.getAbsolutePath()+".png");
				type = "PNG";
			}
			
			try {
				ImageIO.write(imagePanel.getImage(), type, file);
			} catch (Exception e) {
				e.printStackTrace();
				JOptionPane.showMessageDialog(this, "Unable to save file "+file.getName());
			}
		}
	}
1299388
public void savePNGKMNumRisk(String fileName) {
		if (fileName.startsWith("null") || fileName.startsWith("Null") || fileName.startsWith("NULL")) {
			return;
		}
		this.fileName = fileName;

		NumbersAtRiskPanel numbersAtRiskPanel = new NumbersAtRiskPanel();
		numbersAtRiskPanel.setKaplanMeierFigure(this);
		numbersAtRiskPanel.setSize(this.getWidth(), numbersAtRiskPanel.getHeight());
		BufferedImage imageKM = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_RGB);
		Graphics2D graphics2D = imageKM.createGraphics();

		this.paint(graphics2D);

		BufferedImage imageNumRisk = new BufferedImage(numbersAtRiskPanel.getWidth(), numbersAtRiskPanel.getHeight(), BufferedImage.TYPE_INT_RGB);
		Graphics2D graphics2DNumRisk = imageNumRisk.createGraphics();
		numbersAtRiskPanel.paint(graphics2DNumRisk);


		BufferedImage image = new BufferedImage(numbersAtRiskPanel.getWidth(), numbersAtRiskPanel.getHeight() + this.getHeight(), BufferedImage.TYPE_INT_RGB);
		Graphics2D g = image.createGraphics();

		g.drawImage(imageKM, 0, 0, null);
		g.drawImage(imageNumRisk, 0, this.getHeight(), null);

		try {
			ImageIO.write(image, "png", new File(fileName));
		} catch (Exception ex) {
			ex.printStackTrace();
		}

	}
561941
public static void saveFile(File file, String content) throws IOException {
        saveFile(file, content, false);
    }