Android File Read readStringFromFile(File file)

Here you can find the source of readStringFromFile(File file)

Description

read String From File

Declaration

public static String readStringFromFile(File file) 

Method Source Code

//package com.java2s;
import java.io.File;
import java.io.FileReader;

public class Main {
    public static String readStringFromFile(File file) {
        FileReader reader = null;
        try {//from  ww w  .j  a  va2s . c  o  m
            reader = new FileReader(file);
            StringBuffer stringBuffer = new StringBuffer();
            char[] buffer = new char[1024];
            int count = 0;
            while ((count = reader.read(buffer)) != -1) {
                stringBuffer.append(buffer, 0, count);
            }
            reader.close();
            return stringBuffer.toString();
        } catch (Exception e) {

        }
        return null;
    }
}

Related

  1. readFileToByte(File file)
  2. readFileToString(String fileName)
  3. readFileToString(String pathToFile)
  4. readFromFile(String filename)
  5. readInstallationFile(File installation)
  6. readTemplate(String filePath)
  7. readTextFile(File file)
  8. loadFile(String str)
  9. getFileContent(File file)