Java FileInputStream Read readFile(String fileName)

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

Description

read File

License

Open Source License

Declaration

private static String readFile(String fileName) throws Exception 

Method Source Code

//package com.java2s;
// *** LICENSING ***

import java.io.*;

public class Main {
    private static String readFile(String fileName) throws Exception {
        FileInputStream reader = null;
        try {/*from www. ja  v a2s  . co m*/
            reader = new FileInputStream(fileName);
            byte[] fileBytes = new byte[reader.available()];

            reader.read(fileBytes);

            return new String(fileBytes);
        }

        finally {
            if (reader != null)
                reader.close();
        }
    }
}

Related

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