OLD | NEW |
(Empty) | |
| 1 package com.google.dartndk; |
| 2 |
| 3 import java.io.File; |
| 4 import java.io.FileOutputStream; |
| 5 import java.io.InputStream; |
| 6 import java.io.IOException; |
| 7 import java.io.OutputStream; |
| 8 |
| 9 import android.app.NativeActivity; |
| 10 import android.content.res.AssetManager; |
| 11 import android.os.Bundle; |
| 12 import android.util.Log; |
| 13 |
| 14 public class DummyActivity extends NativeActivity { |
| 15 @Override |
| 16 public void onCreate(Bundle savedInstanceState) { |
| 17 super.onCreate(savedInstanceState); |
| 18 try { |
| 19 File localDir = getApplicationContext().getDir("dart", 0); |
| 20 String fileSystemPath = localDir.toString(); |
| 21 String assetPath = "dart"; |
| 22 AssetManager assetManager = getAssets(); |
| 23 String[] files = assetManager.list(assetPath); |
| 24 byte[] buffer = new byte[1024]; |
| 25 int read; |
| 26 for (String filename : files) { |
| 27 String dest = fileSystemPath + "/" + filename; |
| 28 Log.w("Dart", "Copying " + dest); |
| 29 InputStream in = assetManager.open(assetPath + "/" + filename); |
| 30 OutputStream out = new FileOutputStream(dest); |
| 31 while((read = in.read(buffer)) != -1){ |
| 32 out.write(buffer, 0, read); |
| 33 } |
| 34 in.close(); |
| 35 out.flush(); |
| 36 ((FileOutputStream)out).getFD().sync(); |
| 37 out.close(); |
| 38 } |
| 39 } catch (IOException ex) { |
| 40 } |
| 41 } |
| 42 } |
OLD | NEW |