Java FileInputStream Read readFile(String imageName)

Here you can find the source of readFile(String imageName)

Description

read File

License

Open Source License

Declaration

public static byte[] readFile(String imageName) 

Method Source Code

//package com.java2s;
/**// w w w  .j  a v a2  s  .c  om
 * based on source code from k5
 * http://www.magentocommerce.com/boards/viewthread/37982/
 *
 * @author Pawel Konczalski <mail@konczalski.de>
 *
 * You are free to use it under the terms of the GNU General Public License
 */

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class Main {
    public static byte[] readFile(String imageName) {
        byte[] buf = null;
        try {
            File file = new File(imageName);
            buf = new byte[(int) file.length()];
            FileInputStream fis = new FileInputStream(file);
            fis.read(buf);
            fis.close();
        } catch (IOException e) {
            System.err.println(e);
        }

        return buf;
    }
}

Related

  1. readFile(String filePath)
  2. readFile(String filePathName)
  3. readFile(String fname)
  4. readFile(String fname)
  5. readFile(String fname)
  6. readFile(String name)
  7. readFile(String path)
  8. Readfile(String path)
  9. readFile(String path)