Java InputStreamReader Read readFile(String nomeFile)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(String nomeFile) throws IOException 

Method Source Code

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

import java.io.FileInputStream;

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

public class Main {
    public static String readFile(String nomeFile) throws IOException {
        InputStream is;// w w  w  . j a  va 2 s . c  om
        InputStreamReader isr = null;

        StringBuilder sb = new StringBuilder();
        char[] buf = new char[1024];
        int len;

        try {
            is = new FileInputStream(nomeFile);
            isr = new InputStreamReader(is);

            while ((len = isr.read(buf)) > 0) {
                sb.append(buf, 0, len);
            }

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

Related

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