Back to project page ShellAndroid.
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.
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; } }