Java FileInputStream Read readFile(String fileName)

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

Description

read File

License

Open Source License

Declaration

public static byte[] readFile(String fileName) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015 Kaloyan Raev.//from   w  w  w .j av  a  2  s. c om
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Kaloyan Raev - initial API and implementation
 *******************************************************************************/

import java.io.FileInputStream;

import java.io.IOException;

public class Main {
    public static byte[] readFile(String fileName) throws IOException {
        FileInputStream in = new FileInputStream(fileName);
        byte[] bytes = new byte[in.available()];
        in.read(bytes);

        in.close();

        return bytes;
    }
}

Related

  1. readFile(String filename)
  2. readFile(String fileName)
  3. readFile(String fileName)
  4. readFile(String filename)
  5. readFile(String filename)
  6. readFile(String filename)
  7. readfile(String filename)
  8. readFile(String filename)
  9. readFile(String fileName)