Android Open Source - ShellAndroid Asset Utils






From Project

Back to project page ShellAndroid.

License

The source code is released under:

Apache License

If you think the Android project ShellAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package z.hol.shellandroid.utils;
//  www.  j  av  a  2 s  .  co m
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import android.content.Context;
import android.content.res.AssetManager;

public class AssetUtils {

  /**
   * ??Asset???????
   * @param context
   * @param fileName
   * @param checkFile ??????????????????????
   * @throws IOException
   */
  public static void extractAsset(Context context, String fileName, boolean checkFile) throws IOException{
    if (!checkFile || !isFileExist(context, fileName)){
      AssetManager manager = context.getAssets();
      InputStream in = manager.open(fileName);
      OutputStream out = context.openFileOutput(fileName, Context.MODE_PRIVATE);
      BufferedOutputStream bout = new BufferedOutputStream(out);
      int iByte = -1;
      while ((iByte = in.read()) != -1){
        bout.write(iByte);
      }
      bout.flush();
      bout.close();
      out.close();
      in.close();
    }
  }
  
  public static boolean isFileExist(Context context, String fileName){
    File fileDir = context.getFilesDir();
    File f = new File(fileDir, fileName);
    boolean exist = f.exists();
        return exist;
  }
}




Java Source Code List

z.hol.shellandroid.AbsReleaser.java
z.hol.shellandroid.CFlagRelease.java
z.hol.shellandroid.Chmod.java
z.hol.shellandroid.Cpu.java
z.hol.shellandroid.DefaultChmod.java
z.hol.shellandroid.LollipopReleaser.java
z.hol.shellandroid.NormalReleaser.java
z.hol.shellandroid.ShellAndroid.java
z.hol.shellandroid.ShellChmod.java
z.hol.shellandroid.Shell.java
z.hol.shellandroid.example.MainActivity.java
z.hol.shellandroid.exception.ShellExecuteException.java
z.hol.shellandroid.utils.AssetUtils.java
z.hol.shellandroid.utils.ShellUtils.java