Java InputStreamReader Read readFile(String location)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(String location) 

Method Source Code


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

import java.io.*;

public class Main {
    public static String readFile(String location) {
        try {/*from  w w w  .  jav  a2s .  c om*/
            InputStream in = new FileInputStream(new File(location));
            BufferedReader reader = new BufferedReader(new InputStreamReader(in));
            StringBuilder out = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                out.append(line);
            }
            reader.close();
            return out.toString();
        } catch (Exception e) {
            System.out.println(String.format("CWD = %s", System.getProperty("user.dir")));
            System.out.println(e);
            return "";
        }
    }
}

Related

  1. readFile(String filePath)
  2. readFile(String filePath)
  3. readFile(String filePath)
  4. readFile(String filePath, String charsetName, long lineNow, long lineEnd)
  5. readFile(String input)
  6. readFile(String name)
  7. readFile(String nomeFile)
  8. readFile(String p_filename)
  9. ReadFile(String Path)