Java InputStreamReader Read readFile(String fileName)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(String fileName) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;
import java.io.FileInputStream;

import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static String readFile(String fileName) throws IOException {
        FileInputStream fis = new FileInputStream(fileName);
        BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));

        StringBuilder sb = new StringBuilder();
        while (in.ready()) {
            String line = in.readLine();
            sb.append(line).append('\n');
        }/*from ww  w .j ava 2s  .  c  o m*/
        in.close();
        fis.close();

        return sb.toString();
    }
}

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)