public static void stringToFile(String string, File file, String charsetName) {
		FileOutputStream fos = null;
		Writer writer = null;
		try {
			try {
				fos = new FileOutputStream(file);
				writer = new OutputStreamWriter(fos, charsetName);
				writer.write(string);
			} finally {
				if (writer != null) {
					writer.close();
				} else if (fos != null) {
					fos.close();
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
public static void stringToFile ( String string , File file , String charsetName ) { FileOutputStream fos = null ; Writer writer = null ; try { try { fos = new FileOutputStream ( file ) ; writer = new OutputStreamWriter ( fos , charsetName ) ; writer . write ( string ) ; } finally { if ( writer != null ) { writer . close ( ) ; } else if ( fos != null ) { fos . close ( ) ; } } } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Writes a string into a file.

@param string
the string
@param file
the file
@param charsetName
encoding of the file