Java FileOutputStream Create writeFile0(File file, CharSequence content, Iterable lines)

Here you can find the source of writeFile0(File file, CharSequence content, Iterable lines)

Description

write File

License

Open Source License

Declaration

private static String writeFile0(File file, CharSequence content, Iterable<?> lines) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    private static String writeFile0(File file, CharSequence content, Iterable<?> lines) {
        PrintWriter out = null;/* w  w w.  j  a va  2s  .  c  o m*/
        try {
            out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
            if (content != null) {
                out.print(content);
            } else {
                for (Object line : lines) {
                    // We could use println, but we'd probably want to make readFile smarter first.
                    out.print(line);
                    out.print("\n");
                }
            }
            return null;
        } catch (IOException ex) {
            return ex.getMessage();
        } finally {
            out.close();
        }
    }
}

Related

  1. writeFile(String p_filename, String p_buffer)
  2. writeFile(String path, byte[] contents)
  3. writeFile(String path, byte[] data)
  4. writeFile(String path, Properties store, String comment)
  5. writeFile(ZipEntry entry, ZipFile zipFile, File file)
  6. writeFileAsBytes(String fullPath, byte[] bytes)
  7. writeFileAsString(final File filePath, final String output, final String charset)
  8. writeFileAsString(String filename, String contents)
  9. writeFileBinary(String filename, byte[]... dataArrays)