Android Text File Read read(File file, boolean raw)

Here you can find the source of read(File file, boolean raw)

Description

read

Declaration

public static String read(File file, boolean raw) throws IOException 

Method Source Code

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class Main{
    public static String read(String fileName) throws IOException {
        return read(new File(fileName));
    }//from   w w w  .  j  ava 2s  .c  o  m
    public static String read(File file) throws IOException {
        return read(file, false);
    }
    public static String read(File file, boolean raw) throws IOException {
        FileInputStream fis = new FileInputStream(file);

        byte[] bytes = new byte[fis.available()];

        fis.read(bytes);

        fis.close();

        String s = new String(bytes, StringPool.UTF8);

        if (raw) {
            return s;
        } else {
            return StringUtil.replace(s, StringPool.RETURN_NEW_LINE,
                    StringPool.NEW_LINE);
        }
    }
}

Related

  1. getFileContent(File file)
  2. getFileContent(File file, String charSet)
  3. getFileResourceText(String path)
  4. read(File file)
  5. read(File file)
  6. read(String file)
  7. read(String fileName)
  8. read(String pathName)
  9. readCipherSuites(String file)