Java BufferedReader Read readFile(final String file)

Here you can find the source of readFile(final String file)

Description

read File

License

Apache License

Declaration

static String readFile(final String file) 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 {
    static String readFile(final String file) throws IOException {
        BufferedReader reader = null;
        try {//w  w w.  ja v  a  2s.c o m
            reader = new BufferedReader(new FileReader(new File(file)));
            final StringBuilder sb = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                sb.append(line);
                sb.append(System.getProperty("line.separator"));
            }
            return sb.toString();
        } finally {
            if (reader != null) {
                reader.close();
            }
        }
    }
}

Related

  1. readFile(final File file)
  2. readFile(final File file)
  3. readFile(final File file)
  4. readFile(final File file)
  5. readFile(final File paramFile, final boolean paramWhitespaces)
  6. readFile(final String fileName)
  7. readFile(final String filename)
  8. readFile(final String fileName)
  9. readFile(final String filePath)