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

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

Description

write the content string to txt file

License

Apache License

Parameter

Parameter Description
content a parameter
filename a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static void writeStringToFile(String content, String filename) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.io.FileWriter;
import java.io.IOException;

public class Main {
    /**/*from  w w  w  .  jav a 2  s.c  o  m*/
     * write the content string to txt file
     * @param content
     * @param filename
     * @throws IOException
     */
    public static void writeStringToFile(String content, String filename) throws IOException {
        File file = new File(filename);
        try (FileWriter fwriter = new FileWriter(file)) {
            fwriter.append(content);
        }
    }
}

Related

  1. writeStringToFile(String content, File targetFile)
  2. writeStringToFile(String content, String encoding, String fileName)
  3. writeStringToFile(String content, String filename)
  4. writeStringToFile(String content, String filename)
  5. writeStringToFile(String content, String fileName)
  6. writeStringToFile(String content, String fileName, boolean append)
  7. writeStringToFile(String content, String filePath)
  8. writeStringToFile(String content, String path)
  9. writeStringtoFile(String content, String path)