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

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

Description

write String To File

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015-2016 Obeo, Inria//from w  ww.  j  a v a2s.c o m
 * 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:
 *       William Piers <william.piers@obeo.fr>
 *     Philippe Merle <philippe.merle@inria.fr>
 *******************************************************************************/

import java.io.BufferedOutputStream;
import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
    public static void writeStringToFile(File file, String content) throws IOException {
        BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(file));
        stream.write(content.getBytes());
        stream.close();
    }
}

Related

  1. writeStringToFile(File f, String content, boolean append)
  2. writeStringToFile(File f, String s)
  3. writeStringToFile(File f, String s)
  4. writeStringToFile(File f, String s)
  5. writeStringToFile(File file, String content)
  6. writeStringToFile(File file, String content)
  7. writeStringToFile(File file, String contents)
  8. writeStringToFile(File file, String data, String encoding)
  9. writeStringToFile(File file, String data, String encoding)