Can copy only 8 files at once!

It drives me crazy! I wrote a small utility to help me with some issues that we are dealing with in the House and he made that move the jpg of the memory of the device on the SD card. The problem I encounter is that there are 57 files on this particular device and my code will copy only 8 files before the slightest error on.  I have marked the place where the problem is with 'TODO' If you want to find the place in the code below.  Basically, it fails when creating the file 9.  I checked the space SD card - that's fine.  I used a different set of files and it still does not work on the file 9.  The file names are very simple, so no problem there.  That's all just weird.

private int moveFilesToCard(String directory, Vector files)
{
    String SDCardDir = "file:///SDCard/Blackberry/Pictures/";
    int index = files.size();
    int count = 0;

    //Main loop through the list of files to be copied
    _screen.updateStatus("Copying files...");
    for( int i = 0; i < index; i++ )
    {
        String name = (String) files.elementAt(i);
        FileConnection iFile;

        try
        {
            // Attempt to open the source file
            _screen.updateStatus("Opening " + directory + name);
            iFile = (FileConnection)Connector.open(directory + name);
            if(!iFile.exists())
            {
                throw new IOException("Input file could not be opened when copying.");
            }

            // Attempt to open the destination file
            _screen.updateStatus("Opening " + SDCardDir + name);
            FileConnection oFile = (FileConnection) Connector.open(SDCardDir + name);
            if(!oFile.exists())
            {
                // Create file if it doesn't exist
                _screen.updateStatus("Creating " + directory + name);
                oFile.create();   //<------- TODO: This is where it fails on the 8th file.
            }

            // Open the input and output streams for copying the file.
            InputStream is = iFile.openInputStream();
            OutputStream os = oFile.openOutputStream();
            _screen.updateStatus("Reading " + name);

            // Copy the data over
            int data = is.read();
            while( data >= 0 )
            {
                os.write(data);
                data = is.read();
            }
            _screen.updateStatus("Writing " + name);
            os.flush();
            count++;

            iFile.close();
            oFile.close();
        }
        catch (IOException e)
        {
            if( Dialog.ask( Dialog.D_YES_NO, "Error opening or creating " + name + ". Continue?" ) == Dialog.NO )
            {
                break;
            }
            e.printStackTrace();
        }
    }
    return count;
}

You can close your connections and streams in the 'finally' section to make sure that they close.

You close the stream, just the connections. You can close the stream too to be sure. BlackBerry has a limit on the number of open connections, you can have.

It should also be a message with your IOException. Check the log output

Tags: BlackBerry Developers

Similar Questions

  • I recently had a virus on my computer and my security system suggested that several files. I think I maybe deleted some files wrong because now I can open only some files.

    I recently had a virus on my computer and my security system suggested that several files. I think I maybe deleted some files wrong because now I can open only some files. I tried to restore my computer to factory settings, but it won't let me open the system restore. I also have an installation disc, but it does not work either. What can I do to get those files or restore to the factory settings? any help would be appreciated

    original title: help!

    Hi AndrewThomas 924,

    Please see the thread following SpiritX troubleshooting for XP:

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_xp-system/how-can-i-remove-fake-Ms-removal-tool-on-Win-XP/35a66f81-7064-E011-8dfc-68b599b31bf5

    I hope this helps!

  • I can't open several files at once in Photoshop 5. Any suggestions?

    I just install CS5 on my Mac. If I drag multiple files Photoshop to Photoshop icon in my dock only open on my desktop. When I close all the files I tried to open the flash on the screen as they close too, after having been unavailable at this point. Any advice, short to wipe the drive and reinstall everything from scratch?

    Speaking of zero, I have a great record of work available.

    Are you sure they close and are not just rooted tabs?

  • Library: Can I display the file size? Can I import namesake twice?

    Hi, I have two questions regarding the use of Lightroom:

    • Can I display the file size under a thumbnail and I can sort the images by file size? In my view, this is not possible. (Knowing that "Megapixel" is a criterion.)
    • Is it possible to import images with identical names twice, when they are duplicates in different folders? In my view, this is not possible. I believe that you must rename the images in a folder until you can import it again. I believe that you can import only a file name, once, even if the second file is in a different folder.

    Am I wrong?

    Are there other simple things that miss you?

    Thank you.

    You can import a picture with a duplicate file name - just see the file management section in the right of the Module to import Panel and deselect the option that says "don't import suspected duplicates."

    Given that I work with multiple cameras and some of them turned on back to the "0001" in their file numbering sequence, (and new cameras go back to 0001), I have duplicate names stored throughout my catalogue. Or, at least, I did until I started my files to import with a sequence of name custom including the date of name change.

    HD ++

  • Can I copy only the changed files to one external drive to another?

    I have my music files on an external drive with a second copy saved on another external drive. When I add or update the files in iTunes, is there a way I can copy only files that have changed on my second drive without copying them individually?

    Command line terminal use:

    rsync

    Ref: ble-basically-want-to-merge-two-folders http://apple.stackexchange.com/questions/51251/copy-new-files-only-is-this-possi

  • I copied the old file of passwords in the new profile, but do not see.

    Got a new laptop. Copied the content from the old profile to new profile. Most of the old information are there (bookmarks), but I do not see the passwords. I repeated copying the two files key3db and logins.json specifically, but even the passwords saved on my old profile are not there...

    Could you try again in a new profile and copy only the files logins.json and key3db?

    Create a new profile as a test to see if your profile is the source of the problem.

    See "create a profile":

    If the new profile works then you can transfer files from a profile already used in the new profile, but be careful not to copy files corrupted to avoid transporting more problems.

  • Can't see 7 files in the Explorer of Windows 7 slate

    I just got this and try to understand. I see lots of files in file HP Manager but when I plug the Tablet inot my PC I see only 2... DCIM and photos, and has nothing under them (except a picture I took) as well as a file that I created. When I try to copy something the PC in the folder I created I get a message: "cannot collapsed copy device not responding or has been disconnected" but I can copy a PDF file of the tablet to the PC. I access to the internal memory as I don't have a microSD yet (if that makes a difference).

    I plugged it as PTP, because if I connect like PSG, Windows Explorer is not recognize and see the tablet.

    For any help or suggestion would be appreciated.

    Just FYI I managed to connect to:

    (a) implementation Option ON developers

    (b) USB debugging WE

    Then I could see the internal memory and the SD card as external storage on my PC.

    Given that the Tablet connects to three other computers as it normally should, I came to the conclusion that the problem is with the installation of Win 7 on my counter top and possibly some software conflicts.

  • Text recognition &gt; in multiple files - limit only PDF files?

    I have a number of files PDF image scanned in a complex folder structure.  I have Adobe Acrobat Pro XI and tools > text recognition > in several files is amazing.  I was able to convert the scanned image PDFs into place and replace the original PDF files with the converted version on (a backup copy of the folder structure) and course files.  But I have other documents not PDF interspersed in the same folder structure and it converts them to pdf allowing the research as well.  How can I limit the process only convert PDF files?  I don't need a PDF version of the MS Office and other files in the whole of the structure.


    Thanks in advance!

    Bill

    How can I limit the process only convert PDF files?

    Not possible with Acrobat XI. You can copy the PDF files in a separate folder and perform OCR on these files.

  • copy my files and once completed they were in zip files, now I can not open zip files, I use vista bussiness... Thank you.

    make backup of my files aand ordibary copy in zip files, they now need to open and I get message cannot open files, etc.

    You must use the restore backup procedure to restore individual files of access - you can not access it just directly from the backup (even if it's possible with 3rd party software - you can check Bing, Google,www.tucows.com and www.download.com).  If you made a backup of the complete picture, you should definitely 3rd party software even be able to do as you cannot access the individual with restore files (only if doing a restore completes).

    Here is an article on the restore procedure:http://www.vista4beginners.com/How-to-restore-files to make sure you do this right.  It's a selective restore of a full or selective backup (not a full restore from a full backup)...

    This is a GREAT article on the backup and restore processes in Vista http://technet.microsoft.com/en-us/magazine/2007.09.backup.aspx , but he won't go into detail about the restoration process - considering almost as easy, of course.  But it teaches you a lot about what is possible and how to do it.  It also focuses primarily on the full backup process, but he did mention the full backup and restore process as well.

    Here is an article on the advanced use of restoration (during normal restore does not work):http://www.mayankraichura.com/post/2009/08/06/Avdvanced-Restore-via-Windows-Vista-Backup-and-Restore-Center.aspx.

    Restore files from a backup
    http://Windows.Microsoft.com/en-us/Windows-Vista/restore-files-from-a-backup

    Back up and restore: frequently asked questions
    http://Windows.Microsoft.com/en-us/Windows-Vista/back-up-and-restore-frequently-asked-questions

    I also found the following (but don't know if it of true or not):

    1. after the start of "backup and Restore Center."

    2. I chose "Advanced Restore"

    3. I was did not an administrator password... maybe because my account is an administrator account.

    4 choose "files from a backup made on a different computer.

    5. in the dialog box indicating "Select the location of the backup to restore", select "hard drive, CD or DVD...". »

    6. under the drop-down list box, select your drive/partition and continue

    7. If all the backups on your drive, it will show a list of them.

    8. in my case, he showed a backup, but in the backup location, it will show "backup location is not available."

    9. I was frustrated, but then I somehow just select this backup (Yes... even if he said that thebackup location is not available " ")

    10. and you press "next".

    11 guess what... no error!

    12. a window appeared asking me if I wanted to do a full restore, or I want to select specific folders or files.

    13. I selected the folders I wanted to restore and bingo... it their restored smoothly.

    14. so that the next time see a mistake, try to continue with him... ;)

    I don't know if this will help, but it does not provide much information about the process (when it works).

    I hope this helps.

    Good luck!

    Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • How can I copy only new or changed files in windows 7?

    I want to copy files or folders to one disc to another on Windows 7.  But I don't want Windows to copy all the files and replace existing ones.  I just it copies new or changed files.

    You can review SyncToy because it will allow you to do what you want (automatically!).

    SyncToy 2.1
     http://www.Microsoft.com/download/en/details.aspx?ID=15155

    Kind regards

  • Extraction of files from a time capsule that contains data of 3 different MacBooks. If I added a new macbook but I wanted only to select files. How can I find these files?

    If I have 3 different MacBooks stored on time capsule but I want only to add the files selected to a new macbook how I do it,

    find and retrieve files from these devices? How to retrieve the complete set of files for an individual device?

    If I wanted to get back anything, what is the process for this?

    Thank you

    Bill

    The correct method is to migrate. Use the migration assistant in the Utilities folder.

    However migrate doesn't have the fine selection you're after, if you do not want the entire folder like documents.

    You could find to manual aperture and copy the sparsebundle to Time Machine works ok... Use just traverse other disks of the main options of TM TM it in the dock.

    It might not allow you to recover files but I found that I could copy them into TM and then paste the files by jumping out to finder.

    Or you can migrate to another place is to say USB drive plugged into the computer and then retrieve files in a simple copy and paste... Although permissions can be a pain, and you must correct them before you can copy stuff to your own computer files.

  • Satellite P30 - DVD UJ - 830 s problems - you can't copy or move files

    Hello
    Just had to reinstall everything using the Toshiba Recovery disk image.

    DVD drive works at all, which always gives a drive not connected WARNING!

    Then after 2 days and reinstall OLD records, he began to work.

    Now, I can't move a file by copying and pasting, and it does not even appear on SEND it to the list!

    I can read without problem, I can write using the power to go, but I can't write by simply moving a file it! I'll try InCD again and hope it works this time.

    Any idea? I checked the uptade files and firmware, but they are not for this drive, apparently the UJ-830 almost does not exist online at all! Toshiba has got rid of them with all their version (not the Pro) Satellite P30.

    It's a rug * a (Matsu * a - i.e. Panasonic!) UJ-830 S

    Does anyone know were to find hardware manual internal Satellite P30, so I can make the appropriate myself upgrade! I am a technician in electronics and likes to do things correctly.

    This DVD player, in my opinion, is the only let down on this laptop very nice.

    Thank you

    Hello

    You have suggested that you can read without any problems and writing also works using the power to go. I guess the power to go is burning software.
    In this case I think the disk is ok.

    I think that if you want to write the files to the CD using the file just go you must activate Windows registry.
    Go to the properties of disk (right-click) and select? record? tab.
    There, you should check the options.

  • Windows.Old - Can I load the entire file at once my computer is restored with it's info earlier?

    original title: Windows to restore the old windows.old file

    Hi all. I recently had to reinstall my os after that sp1 problems (thanks a lot to Microsoft) I now have a windows.old folder with all of my old saved stuff. Question is, can I load the entire file at once my computer is restored with it's info earlier? Pls let me know. Thanks in advance

    Hello

    None

    You can not load the whole file

    Windows.Old is not to restore your computer

    You can only recover data from the windows.old folder

    programs need to be reinstalled from the original media

    Read about the windows.old folder

    How to restore your personal files after you perform a custom Windows Vista or Windows 7 installation

    http://support.Microsoft.com/kb/932912

  • A network computer can see only some of the files on another computer in network

    We have a network of working with 10 computers on this subject.  One of the computers has been replaced this week.  All computers run Windows 7.

    The new computer can see other computers on the network and it can enter the public folders on these computers, but once it is in a folder, you may not see everything that is in the folder.  You can see subfolders and files of worksheet, but he can't see the other subfolders and other spreadsheet files.  The question is where we keep our customer quotes, so he has many years of activity in it and must be accessible to many people.  All other computers on the network can see everything that is in this issue of the quote, so it doesn't seem to be a problem with the security settings on the folder of the quotation or the computer hosting it.

    The new computer is the only one with office 2016.  It occurred to me that maybe the 2016 office cannot see files created with some older versions of Office (as stupid and irritating as this would be), but I still expect to see all of the subfolders.  I expect also the spreadsheet files to be included, even if they could not be opened.  But they are not yet listed.

    We tried to restart both the computer and housing the bid documents.  Nothing has changed.

    I have never seen it before.  I would have an idea what to look for if he saw not a computer full or could not access a folder on a network computer, but I can't find anything to explain why some of the subfolders and files in a folder accessible otherwise are invisible by a single computer in a network.

    I would appreciate any suggestion or idea.

    Hello

    Thank you for visiting Microsoft Community and we provide a detailed description of the issue.

    I suggest you to send your request in the TechNet forums to get the problem resolved.

    Please visit the link below to send your query in the TechNet forums:

    https://social.technet.Microsoft.com/forums/en-us/home?category=w7itpro

    Hope this information is useful. Please come back to write to us if you need more help, we will be happy to help you.

  • Windows Easy Transfer can only transfer files

    I created an easy transfer file in my previous installation of Windows 7 Ultimate 32 bit. After formatting and installing Windows 7 Ultimate 32 bit even once, I got the following error:

    "Windows Easy Transfer can only transfer files

    Your easy transfer file was created on a computer that is running a different language than this computer. Windows Easy Transfer only transfers files between computers with different languages. Settings will not be transferred. »

    The problem is that the two facilities were in English...

    -What can I do to solve this problem or my parameters are irretrievably lost?

    You can see your language here: HKLM\SYSTEM\CurrentControlSet\Control\CMF\SqmData\BootLanguages. Are the same in the two versions of Windows?

Maybe you are looking for

  • nothing is displayed in my address bar or change when I click on another site and my home page does not open when firefox starts

    for a few weeks or so, whenever I connect to firefox, my home page does not open, and my address bar remains empty. in fact the only time where something appears in my address bar is when I manually type it in., I have also the status of loading Web

  • Has no BIOS on Satellite L850

    Hello world! I have a L850 (PSKG8A-05J001) who stopped booting after the latest bios updated from the Toshiba Web site.To fix the problem, I ordered a Taiwan flashed bios, but they had used the same bios version and the screen remained black. So I as

  • Portege R830 - Free WiFi does not

    So happy my wife bought me a new Portege R830 for my 60th birthday. Went to Wethersppoons to use their WiFi that I do not have WiFi at home and took it and my old phone old piece of junk. Can't get my R830 at work what either on a dial-up speed and t

  • Cannot access previously accessible Web site

    I'm unable to connect to a Web site that I have already connect to a maximum until 3 days ago. Now, I receive the following message: The connection has expired The server to www.risingpenny.com takes too long to respond. The site may be temporarily u

  • Could not get the "EPrint printer Code" no Services Web Page.

    I am trying to connect my impression to the Eprint Services. When I get to the IP given to me by the Configuration Page I printed, I you and can not find a tab HP Webservices to print the button print information sheet. I have a HP LaserJet Pro CP102