Java Text File Save setText(File file, String text)

Here you can find the source of setText(File file, String text)

Description

set Text

License

Open Source License

Declaration

public static void setText(File file, String text) throws Exception 

Method Source Code


//package com.java2s;
/*---------------------------------------------------------------
*  Copyright 2011 by the Radiological Society of North America
*
*  This source software is released under the terms of the
*  RSNA Public License (http://mirc.rsna.org/rsnapubliclicense)
*----------------------------------------------------------------*/

import java.io.*;

public class Main {
    public static void setText(File file, String text) throws Exception {
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
        bw.write(text, 0, text.length());
        bw.flush();//from  w w w  . jav a  2 s  . c  o m
        bw.close();
    }
}

Related

  1. serialize(final File folder, final String content, final String fileName)
  2. writeFile(ArrayList lines, String dest_path)
  3. writeFile(Collection emailTree, String destFile)
  4. writeFile(File destinationFile, String contents, String encoding)
  5. writeFile(File outputDirectory, String fileName, String source)