Back to project page hellomap3d-android.
The source code is released under:
MIT License
If you think the Android project hellomap3d-android 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 com.nutiteq.hellomap3.util; //from w w w .j av a 2 s .c o m import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import android.content.res.AssetManager; import android.util.Log; import com.nutiteq.advancedmap3.Const; public class AssetCopy { public static void copyAssetToSDCard(AssetManager assetManager, String fileName, String toDir) throws IOException { InputStream in = assetManager.open(fileName); File outFile = new File(toDir, fileName); // TODO jaak - check if storage is available and has enough space if(outFile.exists()){ Log.d(Const.LOG_TAG, "file already exits: "+outFile.getAbsolutePath()); return; } OutputStream out = new FileOutputStream(outFile); copyFile(in, out); in.close(); in = null; out.flush(); out.close(); out = null; } private static void copyFile(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[1024]; int read; while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } } }