code: public static boolean writeStringToFile(final File file, final String string2write,
  		final String encoding) throws FileNotFoundException, IOException
  	{
  		boolean iswritten = true;
  		try (FileOutputStream fos = new FileOutputStream(file);
  			BufferedOutputStream bos = new BufferedOutputStream(fos);
  			OutputStreamWriter osw = (null == encoding)
  				? new OutputStreamWriter(bos)
  				: new OutputStreamWriter(bos, encoding);
  			PrintWriter printWriter = new PrintWriter(osw);)
  		{
  			printWriter.write(string2write);
  		}
  		return iswritten;
  	}
docs: The Method writeStringToFile(File, String, String) writes the String to the File.
  
  @param file
  The File to write the String.
  @param string2write
  The String to write into the File.
  @param encoding
  The encoding from the file.
  @return The Method return true if the String was write successfull to the file otherwise
  false.
  @throws FileNotFoundException
  is thrown if an attempt to open the file denoted by a specified pathname has
  failed.
  @throws IOException
  Signals that an I/O exception has occurred.