Saves the actual screenshot without interrupting the running of the
tests. It will log an error if unable to store take the screenshot.

@param file
the file that will store the screenshot
171750
private void silentlySaveScreenshotTo(final File file) {
		try {
			saveScreenshotTo(file);
			LOG.info("Screenshot saved: " + file.getAbsolutePath());
		} catch (Exception e) {
			LOG.warn("Error while taking screenshot " + file.getName() + ": "
					+ e);
		}
	}
441487
def screenshot(self, filename=None):
        
        if self.__keep_screen:
            return self.__last_screen
        try:
            screen = self._take_screenshot()
        except IOError:
            # try taks screenshot again
            log.warn("warning, screenshot failed [2/1], retry again")
            screen = self._take_screenshot()
        self.__last_screen = screen
        if filename:
            save_dir = os.path.dirname(filename) or '.'
            if not os.path.exists(save_dir):
                os.makedirs(save_dir)
            screen.save(filename)
        return screen
1318945
public void addFile(File file) {
        if (file != null && file.exists()) {
            try {
                classPath.add(file.toURI().toURL());
            } catch (MalformedURLException e) {
                throw new AssertionError("converting an existing file to an url should have never thrown an exception!");
            }
        }
    }
980610
public void saveFile(File file, String type)
   {
      try
      {
         Class<? extends ProjectWriter> fileClass = WRITER_MAP.get(type);
         if (fileClass == null)
         {
            throw new IllegalArgumentException("Cannot write files of type: " + type);
         }

         ProjectWriter writer = fileClass.newInstance();
         writer.write(m_projectFile, file);
      }

      catch (Exception ex)
      {
         throw new RuntimeException(ex);
      }
   }
84313
def save_fileAs(self, file=None):
        

        file = file or umbra.ui.common.store_last_browsed_path(
            QFileDialog.getSaveFileName(self, "Save As:", self.__file))
        if not file:
            return False

        return self.write_file(foundations.strings.to_string(file))
299764
public static void storeByteArrayToFile(final byte[] data, final File file) throws IOException
	{
		try (FileOutputStream fos = new FileOutputStream(file);
			BufferedOutputStream bos = new BufferedOutputStream(fos);)
		{
			bos.write(data);
			bos.flush();
		}
	}
957802
public void persist(File file) throws IOException {
    //System.err.println("Writting "+wordMap.size()+" words and "+gramSet.size()+" n-grams");
    DataOutputStream output = new DataOutputStream(new GZIPOutputStream(new FileOutputStream(file)));
    output.writeUTF(FILE_TYPE);
    System.err.println("pruning from "+wordMap.size());
    for (Iterator ki=wordMap.iterator();ki.hasNext();) {
      String key = (String) ki.next();
      if (((CountedNumberedSet) wordMap).getCount(key) < cutoff) {
        ki.remove();
      }
    }
    System.err.println("pruning to "+wordMap.size());
    output.writeInt(wordMap.size());
    for (Iterator ki=wordMap.iterator();ki.hasNext();) {
      String key = (String) ki.next();
      output.writeUTF(key);
      output.writeInt(wordMap.getIndex(key));
    }
    CountedSet cset = (CountedSet) gramSet;
    int gramCount = 0;
    for (Iterator gi = gramSet.iterator();gi.hasNext();) {
      NGram ngram = (NGram) gi.next();
      if (cset.getCount(ngram) >= cutoff) {
        int[] words = ngram.getWords();
        output.writeInt(words.length);
        for (int wi=0;wi<words.length;wi++) {
          output.writeInt(words[wi]);
        }
        gramCount++;
      }
      else {
        //System.err.println("ngram "+cset.getCount(ngram));
      }
    }
    System.err.println("Wrote out "+gramCount+" n-grams");
    output.close();
  }
328311
public void save() throws IOException
    {
        try
        {
            Future<Void> task = saveNB();
            task.get();
        }
        catch (ExecutionException e)
        {
            Throwable t = e.getCause();

            if (t instanceof IOException)
            {
                throw (IOException)t;
            }

            throw new IOException(t);
        }
        catch (InterruptedException e)
        {
            throw new IOException("Saving of the properties file \"" + getFile().getAbsolutePath()
                                  + "\" was interrupted.");
        }
    }
954405
public static void saveBytesToFile(byte[] data, File file) {
		if (data == null) {
			return;
		}
		FileOutputStream fos = null;
		BufferedOutputStream bos = null;
		try {
			fos = new FileOutputStream(file);
			bos = new BufferedOutputStream(fos);
			bos.write(data);
			bos.flush();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (bos != null) {
				try {
					bos.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if (fos != null) {
				try {
					fos.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
1221027
public void save() throws FileNotFoundException {
    PrintStream p = new PrintStream(file);
    p.println(COMMENT_PREFIX + "Saved ELKI settings. First line is title, remaining lines are parameters.");
    for (Pair<String, ArrayList<String>> settings : store) {
      p.println(settings.first);
      for (String str : settings.second) {
        p.println(str);
      }
      p.println();
    }
    p.close();
  }
1296652
public static void saveFile(final File file, byte[] fileContents) throws IOException {
        if (file.isDirectory()) {
            throw new IOException("Unable to save file contents as a directory.");
        }

        final FileOutputStream fos = new FileOutputStream(file);
        fos.write(fileContents);
        fos.flush();
        fos.close();
    }
270248
public static void storeCache(Map<String, String> map, File file) {
        BufferedWriter bw = null;
        try {
            // Ensure that we the directory exists (maybe this should be done at
            // another place).
            file.getParentFile().mkdirs();
            bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
            for (Entry<String, String> en : map.entrySet()) {
                bw.write(en.getValue());
                bw.write(' ');
                bw.write(en.getKey());
                bw.write('\n');
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            FileUtil.closeAndIgnoreExceptions(bw);
        }
    }
1018138
public synchronized void save(String persistence) {
		try {
			createObjectMapper().writeValue(new File(persistence), tableList);
		} catch (IOException e) {
			e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
		}
	}
79177
public void copyLogs(@NonNull File file, Callback<File> callback) {
        adapter.adapt(super.copyLogs(file), callback);
    }
523966
public void file(File file) {
        try {
            contentLength(file.length());
            file(file.getName(), new FileInputStream(file));
        } catch (FileNotFoundException e) {
            throw new PippoRuntimeException(e);
        }
    }
325231
public void restoreFromFile(File file) throws IOException
    {
        byte[] rawData = new byte[(int) file.length()];
        ByteBuffer bufData = null;
        FileInputStream fis = null;
        DataInputStream dis = null;
        try {
            fis = new FileInputStream(file);
            dis = new DataInputStream(fis);
            dis.readFully(rawData);
            bufData = ByteBuffer.wrap(rawData);
            restoreFromBuffer(bufData);
        }
        finally {
            if (dis != null) {
                dis.close();
            }
            if (fis != null) {
                fis.close();
            }
        }
    }
789812
public void saveTo(File propertyFile) throws IOException {
        Properties props = new Properties();
        props.put("username", username);
        props.put("key", accessKey);
        FileOutputStream out = new FileOutputStream(propertyFile);
        try {
            props.store(out, "Sauce OnDemand access credential");
        } finally {
            out.close();
        }
    }