Java Text File Write writeStringToFile(String str, File file)

Here you can find the source of writeStringToFile(String str, File file)

Description

write String To File

License

Open Source License

Declaration

public static void writeStringToFile(String str, File file) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing./*from  w w  w  . j  a v  a  2  s . com*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.OutputStreamWriter;

public class Main {
    public static void writeStringToFile(String str, File file) throws IOException {
        OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
        char[] chars = str.toCharArray();
        out.write(chars, 0, chars.length);
        out.close();
    }
}

Related

  1. writeStringToFile(String s, File file)
  2. writeStringToFile(String s, String filename)
  3. writeStringToFile(String s, String filePathname)
  4. writeStringToFile(String sdat, File f)
  5. writeStringToFile(String str, File file)
  6. writeStringToFile(String str, File file)
  7. WriteStringToFile(String str, String file)
  8. writeStringToFile(String str, String filePath)
  9. writeStringToFile(String str, String filePath)