Java FileInputStream Read readFile(String fileName)

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

Description

DOCUMENTME.

License

Apache License

Parameter

Parameter Description
fileName DOCUMENTME

Exception

Parameter Description
IOExceptionDOCUMENTME

Return

DOCUMENTME

Declaration

private static String readFile(String fileName) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {
    /**//from  w ww  .j  ava 2  s.  c  om
     * DOCUMENTME.
     *
     * @param   fileName  DOCUMENTME
     *
     * @return  DOCUMENTME
     *
     * @throws  IOException  DOCUMENTME
     */
    private static String readFile(String fileName) throws IOException {
        byte[] cont = null;
        File file = new File(fileName);
        FileInputStream fi = new FileInputStream(file);

        try {
            long len = file.length();
            cont = new byte[(int) len];
            fi.read(cont);
        } finally {
            fi.close();
        }

        return new String(cont, "UTF-8");
    }
}

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)