Java Byte Array from getBytesFromArrayList(final ArrayList fileList)

Here you can find the source of getBytesFromArrayList(final ArrayList fileList)

Description

TODO

License

Open Source License

Parameter

Parameter Description
fileList TODO

Exception

Parameter Description
IOException TODO

Return

TODO

Declaration

public static byte[] getBytesFromArrayList(final ArrayList<File> fileList) throws IOException 

Method Source Code


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

import java.io.ByteArrayOutputStream;
import java.io.File;

import java.io.IOException;

import java.io.ObjectOutput;
import java.io.ObjectOutputStream;

import java.util.ArrayList;

public class Main {
    /**/*  w ww.  j  a v a2  s . co m*/
     * TODO
     * 
     * @param fileList
     *            TODO
     * @return TODO
     * @throws IOException
     *             TODO
     */
    public static byte[] getBytesFromArrayList(final ArrayList<File> fileList) throws IOException {
        // TODO besser arrayList<String>?
        byte[] yourBytes;
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutput out = null;
        try {
            out = new ObjectOutputStream(bos);
            out.writeObject(fileList);
            yourBytes = bos.toByteArray();
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
                if (bos != null) {
                    bos.close();
                }
            } catch (IOException ex) {
                // ignore close exception
            }
        }

        return yourBytes;
    }
}

Related

  1. getBytesAndClose(InputStream in)
  2. getBytesArrayFromFile(String fileName)
  3. getBytesASCII(String s)
  4. getBytesAsTempFile(byte[] bytes)
  5. getBytesClassic(final int count, final InputStream is)
  6. getBytesFromHexaText(String text)
  7. getBytesFromImage(File file)
  8. getBytesFromInt(int value)
  9. getBytesFromList(List values)

    HOME | Copyright © www.java2s.com 2016