Android Text File Read readFileSdcard(File file)

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

Description

read File Sdcard

Declaration

public static String readFileSdcard(File file) throws Exception 

Method Source Code

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

import org.apache.http.util.EncodingUtils;

public class Main {
    public static String readFileSdcard(File file) throws Exception {
        String res = "";
        FileInputStream fin = new FileInputStream(file);
        int length = fin.available();
        byte[] buffer = new byte[length];
        fin.read(buffer);/*from w w  w . j ava  2 s .c  o  m*/
        res = EncodingUtils.getString(buffer, "UTF-8");
        fin.close();
        return res;
    }
}

Related

  1. readTextFile(String filePath)
  2. readTextFile(String path)
  3. setFileResourceText(String path, String content)
  4. getContent(String file, String encodType)
  5. getString(File file)
  6. readFromFile(Context context, String fileName)
  7. loadTextFile(Context context, String textFile)