Java BufferedReader Read All readAll(String path)

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

Description

read All

License

Open Source License

Declaration

public static String readAll(String path) throws FileNotFoundException, IOException 

Method Source Code

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

import java.io.BufferedReader;

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

public class Main {
    public static String readAll(String path) throws FileNotFoundException, IOException {
        BufferedReader br = new BufferedReader(new FileReader(path));
        StringBuilder sb = new StringBuilder();
        try {// w  w w .ja v  a 2 s .  c o  m
            String line = br.readLine();

            while (line != null) {
                sb.append(line);
                sb.append(System.lineSeparator());
                line = br.readLine();
            }
        } finally {
            br.close();
        }
        return sb.toString();
    }
}

Related

  1. readAll(String fileName)
  2. readAll(String fileName)
  3. readAll(String filePath)
  4. readAll(String filePathAndName)
  5. readAll(String ip)
  6. ReadAll_Variant2(Reader rd, Writer wr)
  7. readAllCourseNum()
  8. readAllCoursePro()
  9. readAllCourseTime()