diff options
| author | Lioncash <mathew1800@gmail.com> | 2013-10-09 12:35:12 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2013-10-09 12:35:12 -0400 |
| commit | 0dd32986b8308e72c64f337217f933f8a74913fe (patch) | |
| tree | 41b28cf21f896f519d597cd9778ca7a3bd241310 /Source/Android/src/org | |
| parent | 414ed6ef63f5e0cdc4edb10e0d1267535c41d5a9 (diff) | |
{Android] Eliminate need for even using a byte array when copying assets over.
Diffstat (limited to 'Source/Android/src/org')
| -rw-r--r-- | Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java index b06669f8f7..9d4eb6c42f 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java @@ -11,10 +11,12 @@ import android.content.Intent; import android.os.Bundle; import android.os.Environment; import android.util.Log; + import org.dolphinemu.dolphinemu.gamelist.GameListActivity; import org.dolphinemu.dolphinemu.settings.UserPreferences; import java.io.*; +import java.nio.channels.FileChannel; /** * The main activity of this emulator front-end. @@ -23,16 +25,22 @@ public final class DolphinEmulator extends Activity { private void CopyAsset(String asset, String output) { - InputStream in = null; - OutputStream out = null; - try { - in = getAssets().open(asset); - out = new FileOutputStream(output); - copyFile(in, out); - in.close(); - out.close(); + // Get input file channel. + FileInputStream inStream = getAssets().openFd(asset).createInputStream(); + FileChannel in = inStream.getChannel(); + + // Get output file channel. + FileOutputStream outStream = new FileOutputStream(output); + FileChannel out = outStream.getChannel(); + + // Copy over + in.transferTo(0, in.size(), out); + + // Clean-up + inStream.close(); + outStream.close(); } catch (IOException e) { @@ -40,17 +48,6 @@ public final class DolphinEmulator extends Activity } } - private 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); - } - } - @Override public void onCreate(Bundle savedInstanceState) { |
