/**
* 拷贝assets下的文件
*
* @param assetFilePath
* assets的文件路径
* @param to
* 拷贝到的路径
*/
public static void copyAssetFile(String assetFilePath, String to)
{
InputStream inputStream = null;
FileOutputStream fileOutputStream = null;
try
{
inputStream = ApplicationData.globalContext.getAssets().open(
assetFilePath);
File toDir = new File(to);
toDir.mkdirs();
File toFile = new File(
toDir.getAbsolutePath()
+ "/"
+ assetFilePath.substring(assetFilePath
.lastIndexOf("/") + 1));
fileOutputStream = new FileOutputStream(toFile);
byte[] buffer = new byte[BUFFER_SIZE];
for (int bytesRead = 0; (bytesRead = inputStream.read(buffer, 0,
buffer.length)) != -1;)
{
fileOutputStream.write(buffer, 0, bytesRead);
}
} catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
if (inputStream != null)
{
inputStream.close();
}
if (fileOutputStream != null)
{
fileOutputStream.close();
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}