Java Text File Read Line readLines(String fullFileName)

Here you can find the source of readLines(String fullFileName)

Description

read Lines

License

Apache License

Declaration

public static String readLines(String fullFileName) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.BufferedReader;

import java.io.File;
import java.io.FileReader;

import java.io.IOException;

public class Main {
    public static String readLines(String fullFileName) throws IOException {
        FileReader fr = null;/*from   w w  w  .  j  a  v  a 2 s  . c om*/
        BufferedReader br = null;

        try {
            File file = new File(fullFileName);
            fr = new FileReader(file);

            br = new BufferedReader(fr);

            String line = null;
            StringBuffer sb = new StringBuffer();

            while ((line = br.readLine()) != null) {
                sb.append(line);
                sb.append("\n");
            }

            return sb.toString();
        } finally {
            if (br != null) {
                br.close();
            }

            if (fr != null) {
                fr.close();
            }
        }
    }
}

Related

  1. readLines(String filename)
  2. readLines(String fileName)
  3. readLines(String filePath)
  4. readLines(String filePath)
  5. readLines(String filePath)
  6. readLines(String lines)
  7. readLines(String string)
  8. readLines(String targetPath)
  9. readLines(String text)