Java BufferedReader Read readFile(String file)

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

Description

read File

License

Apache License

Declaration

public static String readFile(String file) throws IOException 

Method Source Code


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

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

public class Main {
    public static String readFile(String file) throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader(file));
        String line = null;//from   w  ww .j av  a  2  s  .  c o  m
        StringBuilder stringBuilder = new StringBuilder();
        String ls = System.getProperty("line.separator");

        while ((line = reader.readLine()) != null) {
            stringBuilder.append(line);
            stringBuilder.append(ls);
        }

        return stringBuilder.toString();
    }
}

Related

  1. readFile(String aFileName)
  2. readFile(String directory)
  3. readFile(String directory, String fileName)
  4. readFile(String file)
  5. readFile(String file)
  6. readFile(String file)
  7. readFile(String file)
  8. readFile(String file)
  9. ReadFile(String file)