Java FileInputStream Read readFile(String file)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(String file) throws IOException 

Method Source Code

//package com.java2s;
/**/* w  ww  .j a  va 2s. c  o m*/
 *  Copyright 2011 Oliver Buchtala
 *
 *   This file is part of ndogen.
 *
 *  ndogen is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  ndogen is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with ndogen.  If not, see <http://www.gnu.org/licenses/>.
 */

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

import java.io.IOException;

public class Main {
    public static String readFile(String file) throws IOException {
        int len = (int) (new File(file)).length();
        FileInputStream fis = new FileInputStream(file);
        byte buf[] = new byte[len];
        fis.read(buf);
        fis.close();

        return new String(buf);
    }
}

Related

  1. readFile(InputStream ios)
  2. readFile(InputStream iStream)
  3. readFile(String destination)
  4. readFile(String file)
  5. readFile(String file)
  6. readFile(String file)
  7. readFile(String file)
  8. readFile(String file)
  9. readFile(String filename)