from File via FileInputStream - Android java.io

Android examples for java.io:InputStream

Description

from File via FileInputStream

Demo Code

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Main {

  public static String fromFile(File f) throws IOException {
    InputStream is = new FileInputStream(f);
    byte[] bs = new byte[is.available()];
    is.read(bs);//from   www  .  j  ava 2s. c  om
    is.close();
    return new String(bs);
  }

}

Related Tutorials