Java FileOutputStream Write saveLongList(String file, Collection c, boolean append)

Here you can find the source of saveLongList(String file, Collection c, boolean append)

Description

save Long List

License

Open Source License

Declaration

public static void saveLongList(String file, Collection<Long> c, boolean append)
            throws FileNotFoundException, IOException 

Method Source Code

//package com.java2s;
/*/*from w  w w  .  java2  s.  c om*/
 * Copyright (C) ${year} Omry Yadan <${email}>
 * All rights reserved.
 *
 * See https://github.com/omry/banana/blob/master/BSD-LICENSE for licensing information
 */

import java.io.*;

import java.util.*;

public class Main {
    public static void saveLongList(String file, Collection<Long> c, boolean append)
            throws FileNotFoundException, IOException {
        File p = new File(file).getParentFile();
        if (p != null)
            p.mkdirs();

        FileOutputStream fout = new FileOutputStream(file, append);
        try {
            for (Long subjectID : c) {
                fout.write((subjectID + "\n").getBytes());
            }
        } finally {
            fout.close();
        }
    }

    public static void saveLongList(String file, Collection<Long> c) throws FileNotFoundException, IOException {
        saveLongList(file, c, false);
    }
}

Related

  1. saveInputStream(InputStream _input_stream, File _file)
  2. saveInputStream(InputStream is, String filePath)
  3. saveInt16bit(String filename, int[] intData)
  4. saveIntArrayToFile(int[] array, File file)
  5. saveKeyToFile(String key)
  6. saveProxyClass(String path, String proxyClassName, Class[] interfaces)
  7. saveResouce(String resourceName, String outputFile)
  8. saveStream(InputStream is, File output)
  9. saveStream(InputStream stream, File targetFile)