Java Text File Read readTextFile(String fn)

Here you can find the source of readTextFile(String fn)

Description

read Text File

License

LGPL

Declaration

public static String readTextFile(String fn) throws IOException 

Method Source Code

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

import java.io.FileInputStream;
import java.io.IOException;

public class Main {
    public static String readTextFile(String fn) throws IOException {
        FileInputStream fis = new FileInputStream(fn);
        int numBytes = fis.available();

        byte[] buf = new byte[numBytes];
        fis.read(buf);// ww  w  .  j  a  va  2  s . com
        String content = new String(buf);
        return content;

    }
}

Related

  1. readTextFile(File file, int max, String ellipsis)
  2. readTextFile(final DataInputStream is)
  3. readTextFile(final String path, final String enc)
  4. readTextFile(InputStream inStream)
  5. readTextFile(String fileName)
  6. readTextFileFast(final File file)