Java BufferedReader 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) 

Method Source Code


//package com.java2s;
import java.io.BufferedReader;
import java.io.File;

import java.io.FileReader;
import java.io.IOException;

public class Main {
    public static String readFile(String file) {
        BufferedReader br = null;
        StringBuilder text = new StringBuilder();
        try {/*w w  w  .j  a v a 2  s  . c o  m*/
            br = new BufferedReader(new FileReader(new File(file)));
            String line;
            while ((line = br.readLine()) != null) {
                text.append(line);
            }
        } catch (Exception e) {

        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                br = null;
            }
        }
        return text.toString();
    }
}

Related

  1. readFile(String file)
  2. readFile(String file)
  3. ReadFile(String file)
  4. readFile(String file)
  5. readFile(String file)
  6. readFile(String file)
  7. readFile(String file)
  8. readFile(String file, Boolean deleteOnExit)
  9. readFile(String fileDir)