Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7656591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:48:18+00:00 2026-05-31T12:48:18+00:00

I am trying to copy my Blackberry assets folder to the SD card using

  • 0

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 error: cannot find symbol inConn.close(); & outConn.close();. Can someone please advise what I am doing wrong?

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<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)) > 0) {
        out.write(buf, 0, len);
    }
    in.close();
    inConn.close();
    out.close();
    outConn.close();
}
    String value = "OK";
return new PluginResult(PluginResult.Status.OK, value);
}

I am using Phonegap If that makes any difference. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:48:20+00:00Added an answer on May 31, 2026 at 12:48 pm

    Your are not opening the streams correctly. Instead, you should use a separate FileConnection for source and destination files. Then use
    FileConnection#openInputStream() to open InputStream and FileConnection#openOutputStream() to open OutputStream.

    Code snippet:

    for(int i=0; i<length; i++) {
        try {
            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)) > 0) {
               out.write(buf, 0, len);
            }
    
            in.close();
            srcConn.close();
    
            out.close();
            dstConn.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    

    UPDATE 1: Fixed few typos that caused “cannot find symbol” error.

    UPDATE 2: Surrounded the code with try/catch (catching IOException).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to copy the contents of certain folders to another folder using
I'm trying to copy one form <input> field value to another form using jQuery.
I'm trying to copy a folder from my computer to my android phone using
I am trying to copy a file using this - private void button1_Click(object sender,
I'm trying to copy a directory using the Ant copy task. I am a
I am trying to copy data from my MYSQL table to SQL Server using
I'm trying to copy a QList in a std::vector this is my code: std::copy(_param_31.listJobs->list_USCOREjobs.begin(),
I am trying to copy the string $str = ' this is my string';
when I'm trying to copy an array's element to another using php $new=array(); for($i=0;$i<$num;$i+3){
Im trying to copy a directory to a new location. So I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.