Java InputStreamReader Read readFile(String path)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(String path) 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 path) throws IOException {
        StringBuilder sb = new StringBuilder();
        BufferedReader br = null;
        br = new BufferedReader(new InputStreamReader(new FileInputStream(path), "UTF-8"));

        String line;/*from w w w . jav  a2s .  c  om*/
        if ((line = br.readLine()) != null)
            sb.append(line);
        while ((line = br.readLine()) != null) {
            sb.append(System.getProperty("line.separator"));
            sb.append(line);
        }
        br.close();

        return sb.toString();
    }
}

Related

  1. readFile(String name)
  2. readFile(String nomeFile)
  3. readFile(String p_filename)
  4. ReadFile(String Path)
  5. readFile(String path)
  6. readFile(String path)
  7. readFile(String path)
  8. readFile(String Path)
  9. readFile(String path)