title: Blackberry - How to copy files to SD card using input/output stream?
body: <p>I am trying to copy my Blackberry assets folder to the SD card using the Input/Output stream. However I cannot seem to get this to work. I get an error message when running the Blackberry simulator indicating <code>error: cannot find symbol inConn.close(); &amp; outConn.close();</code>. Can someone please advise what I am doing wrong?</p>
  
  <pre><code>import com.phonegap.api.Plugin;
  import com.phonegap.api.PluginResult;
  import javax.microedition.io.*;
  import javax.microedition.io.file.*;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import org.json.me.JSONArray;
  
  public static PluginResult execute(JSONArray args) {
  String[] resourseFileNames = {"file1","file2"."file3"};
  final int length = resourseFileNames.length;
  
  for(int i=0; i&lt;length; i++) {
      String srcFile = "file:///store/home/user/sample/www" + resourseFileNames[i];
      FileConnection srcConn = (FileConnection) Connector.open(srcFile, Connector.READ);
      InputStream in = srcConn.openInputStream();
      String dstFile = "file:///SDCard/MyAppName/www" + resourseFileNames[i];
      FileConnection dstConn = (FileConnection)Connector.open(dstFile, Connector.WRITE);
      OutputStream out = dstConn.openOutputStream();
      // Copy the bits from instream to outstream
      byte[] buf = new byte[1024];
      int len;
      while ((len = in.read(buf)) &gt; 0) {
          out.write(buf, 0, len);
      }
      in.close();
      inConn.close();
      out.close();
      outConn.close();
  }
      String value = "OK";
  return new PluginResult(PluginResult.Status.OK, value);
  }
  </code></pre>
  
  <p>I am using Phonegap If that makes any difference. Thanks.</p>