Android Text File Write write2File(Set set, String path)

Here you can find the source of write2File(Set set, String path)

Description

write File

Declaration

public static void write2File(Set<String> set, String path) 

Method Source Code

//package com.java2s;

import java.io.BufferedWriter;
import java.io.File;

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

import java.util.Set;

public class Main {

    public static void write2File(Set<String> set, String path) {
        File file = new File(path);
        try {//from ww w.  ja  v a 2  s .  c  o  m
            file.createNewFile();
            BufferedWriter bw = new BufferedWriter(new FileWriter(file));
            for (String str : set) {
                bw.write(str);
                bw.newLine();
            }
            bw.flush();
            bw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. write(File file, String s)
  2. write(File file, String s, boolean lazy)
  3. write(File file, String s, boolean lazy, boolean append)
  4. write(String fileName, String s)
  5. write(String pathName, String fileName, String s)
  6. writeFile(File f, String content)
  7. writeFile(File file, String content)
  8. writeFile(File file, String content)
  9. writeFile(File file, String content, String encoding)