Java FileWriter Write saveContent(String context, String filename)

Here you can find the source of saveContent(String context, String filename)

Description

save Content

License

Apache License

Declaration

public static void saveContent(String context, String filename) 

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 {
    public static void saveContent(String context, String filename) {
        File file = new File(filename);
        if (!file.exists()) {
            try {
                file.createNewFile();//from ww  w  .  j av a 2 s . c om
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
        try {
            FileWriter writer = new FileWriter(file, true);
            writer.append(context);
            writer.flush();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

Related

  1. saveAuthFile(String fileName, String raw)
  2. saveBufferInFile(String buffer, File filename)
  3. saveCCS(Map contributionScore, String diseaseState, String file)
  4. saveColumn(int[] density, String filename)
  5. saveConfig(File conf, Map data)
  6. saveData(Map> data, File file)
  7. saveData(Map> data, String file)
  8. saveData(String fileName, double totalTime, int[] resultSubset)
  9. saveDictionary(String fileName, Map values)