Java InputStreamReader Read readFile(final File file)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(final File file) throws IOException 

Method Source Code

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

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;

import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static String readFile(final File file) throws IOException {

        final StringBuilder sb = new StringBuilder();
        try (final BufferedReader reader = new BufferedReader(
                new InputStreamReader(new FileInputStream(file)))) {
            String line = null;// w ww.j  av a  2 s.c  o m
            while ((line = reader.readLine()) != null) {
                sb.append(line);
                sb.append("\n");
            }
        }
        return sb.toString();
    }
}

Related

  1. readFile(File filename)
  2. readFile(File path)
  3. readFile(File resultFile)
  4. readFile(File target)
  5. readFile(FileInputStream file)
  6. readFile(final File inputFile)
  7. readFile(final String aFileName)
  8. readFile(final String path)
  9. readFile(IFile file)