Getting error in the array : help

Hi i have written following code and getting this error
String srcdir = new String("C:\\projects\\xml\\rwjf-org\\closedgrants\\finalxml\\grr\\");
File fileDir = new File(srcdir);
String[] fileList = new String[100];
fileList = fileDir.list();
for(int i=0; fileList.length>0; i++){
String currFile = srcdir + fileList;
//String fname = new String(fileList[i]);
System.out.print("String file name is " + currFile);
//System.out.print("file name is " + fileList[i]);
ERROR : java.lang.ArrayIndexOutOfBoundsException
I'm new to java.
Please tell me where i'm going wrong.
any help would be great.
Pooja

There are several errors in your code:
String[] fileList = new String[100];
fileList = fileDir.list();
Here you point the fileList reference to a String[] object, and then immediately point the reference to another object. This is a useless creation of an object... the #1 cause of slow Java code.
Write just this instead:
String[] fileList = fileDir.list();
for(int i=0; fileList.length>0; i++){
The condition fileList.length > 0 will forever be true or false. the condition should be i < fileList.length.
I think those suggestions should get you started...

Similar Messages

  • Getting error for the Array : help

    Hi i have written following code and getting this error
    String srcdir = new String("C:\\projects\\xml\\rwjf-org\\closedgrants\\finalxml\\grr\\");
    File fileDir = new File(srcdir);
    String[] fileList = new String[100];
    fileList = fileDir.list();
    for(int i=0; fileList.length>0; i++){
    String currFile = srcdir + fileList;
    //String fname = new String(fileList[i]);
    System.out.print("String file name is " + currFile);
    //System.out.print("file name is " + fileList[i]);
    ERROR : java.lang.ArrayIndexOutOfBoundsException
    I'm new to java.
    Please tell me where i'm going wrong.
    any help would be great.
    Pooja

    Hi i have written following code and getting this
    error
    String srcdir = new
    w
    String("C:\\projects\\xml\\rwjf-org\\closedgrants\\fina
    xml\\grr\\");
    File fileDir = new File(srcdir);
    String[] fileList = new String[100];
    fileList = fileDir.list();If you are not after limiting the number of files returned, change the previous two lines to this one line (then, you will get all files/subdirs contained within the srcdir):
    String[] fileList = fileDir.list();
    for(int i=0; fileList.length>0; i++){And, as another poster mentioned, change your first line of the for loop to this:
    for (int i = 0; i < fileList.length; i++)
    HTH,
    Mike Kares
    String currFile = srcdir + fileList;
    //String fname = new String(fileList[i]);
    System.out.print("String file name is " +
    is " + currFile);
    //System.out.print("file name is " +
    is " + fileList[i]);
    ERROR : java.lang.ArrayIndexOutOfBoundsException
    I'm new to java.
    Please tell me where i'm going wrong.
    any help would be great.
    Pooja

  • My ipad mini 2 is not turning on. I tried to reset with the power/home buttons but it didnt work. I tried to restore it in DFU mode but it didnt work, i get error 4004. Please help me!

    My ipad mini 2 is not turning on. I tried to reset with the power/home buttons but it didnt work. I tried to restore it in DFU mode but it didnt work, i get error 4004. Please help me!

    I also tried the ol' whacking 3 times trick...Didn't work to my surprise

  • I tunes 11 will not let me sync my I pod nano... keep getting error meessage:  the software required for this I pod was not installed correctly... I have tried to reinstall 6 times Dumped everything i tunes related no luck help!

    I recently updated to Itunes 11 and now no sync... get error message: The software required for this I pod was not installed correctly. Please reinstall Itunes to install the required software.  I backed up all music and deleted all related itunes items and still get this error after 6 attempts to reload itunes... i give up please help

    I recently updated to Itunes 11 and now no sync... get error message: The software required for this I pod was not installed correctly. Please reinstall Itunes to install the required software.  I backed up all music and deleted all related itunes items and still get this error after 6 attempts to reload itunes... i give up please help

  • I backed up my movies and rebuild my computer, and after making sure i'm using the latest version of itunes and quicktime and and making sure i still had spare computer authorizations, i still get error 23132.  Please help.

    I backed up my movies and rebuild my computer, and after making sure i'm using the latest version of itunes and quicktime and and making sure i still had spare computer authorizations, i still get error 23132.  Please help.

    I had this exact issue.  Spent over an hour on the phone with apple support, they couldn't resolve.  Here is what I ended up doing, that worked.
    1.  Turned iTunes match off on all my iOS devices
    2.  Deleted the offending playlists from the iOS device they originated on
    3.  Started iTunes, let it run (literally) for an hour before it became responsive.  First thing I did, before clicking anywere else was disable iTunes match.  If I clicked anywhere, it would clock for another hour.
    4.  Let iTunes run overnight, by morning it had cleaned out the repeating play lists.  This got my Mac/iTunes back to an operable state.
    5.  Restore iPhones from backup in iTunes.
    What was causing my issue was a single playlist that was created on an iPhone, then suddenly showed up with several thousand duplicates on my other iPhone.  The culprit playlist did not, for some reason, duplicate itself on my two iPads.  Apple support seemed to think it was because the problem iPhone tried to sync the playlist to iCloud over and over again unsuccessfully, then it finally went through and populated the thousands of blank/failed playlists which then tried to propigate to iTunes and my other iOS devices.  Seems like a reasonable theory.
    I have not yet re-enabled iTunes match.  So, no idea what will happen if I decide to go back down that rabbit hole.

  • HT201210 I have an old i phone 3G and do not know the password for it. trying to restore it from itunes but keep getting error code 1015, any help on how to get passed this please?

    I have an old i phone 3G and do not know the password for it. trying to restore it from itunes so my daughter can use it as an ipod but keep getting error code 1015, any help on how to get passed this please?

    Hi ratcat14!
    I have an article that can help you troubleshoot this issue:
    Resolve specific iTunes update and restore errors
    http://support.apple.com/kb/ts3694
    Check for hardware issues
    Try to restore your iOS device two more times while connected with a cable, computer, and network you know are good. Also, confirm your security software and settings are allowing communication between your device and update servers. If you still see the alert when you update or restore, contact Apple support.
    Common errors: 1, 10-47, 1002, 1011, 1012, 1014, 1000-1020.
    Thanks for being a part of the Apple Support Communities!
    Cheers,
    Braden

  • HT1338 My kid down loaded mackeeper and now I can not get rid of it.  I have tried all techniques suggesting on several sites and still can not empty the trash can.  keep getting error code -8003.  Help.

    My kid down loaded mackeeper and now I can not get rid of it.  I have tried all techniques suggesting on several sites and still can not empty the trash can.  keep getting error code -8003.  Help.

    http://reviews.cnet.com/8301-13727_7-20020873-263.html
    This should help you empty what's currently in the trash, but is no guarantee you got everything related to MacKiller off the drive. See Ogelthorpe's link.

  • Trying to restore/update 3rd gen ipod touch - keep getting error message - THe ipod touch could not be restored. An unknow error occurred (-1). Please help.

    Please Help..
    Trying to restore / update ipod 3rd generation - keep getting error message - The ipod touch could not be restores. An unknown error occurred (-1).

    Error 1 or -1
    This may indicate a hardware issue with your device. Follow Troubleshooting security software issues, and restore your device on a different known-good computer. If the errors persist on another computer, the device may need service.
    The "device may need service" means a hardware problem. in that case make an appointment at the Genius Bar of an Apple store.
    Apple Retail Store - Genius Bar

  • Keep getting error message "The registry settings used by the iTunes drivers for importing and burning CDs ....please reinstall iTunes." I have done this several times but it doesn't help.

    Keep getting error message "The registry settings used by the iTunes drivers for importing and burning CDs ....please reinstall iTunes." I have done this several times but it doesn't help.

    Refer to this article:
    iTunes for Windows: "Registry settings" warning when opening iTunes
    http://support.apple.com/kb/TS3299

  • Open script cannot get connection from the brower helper after 15 seconds.

    Error:
    ===
    Open script cannot get connection from the brower helper after 15 seconds. Do you want to continue waiting for the browser to load?
    Please Note:
    ========
    1. I have tried this only on IE
    2. I am running OATS on a Remote desktop
    Situation:
    ======
    Trying to stop the recording
    Try to get xpath of an object using Inspect Path
    Setup details
    ========
    Windows XP 5.1 Service Pack 3, x86
    OpenScript 12.1.0.1.383
    Internet Explorer 8.0.6001.18702
    FireFox 13.0.1
    Mitigation steps done till now:
    ==================
    1. Disabled windows firewall
    2. Disable XSS filter setting
    3. Restarted the ATS services (3 of them)
    4. Run the Open Script Diagnosis Tool (PS: There are 3 errros even after running it. The 3 errros are listed in the workspace_log log file snippet below...)
    Error in worspace_log:
    =============
    To Change setting:
    Go to Tools > Internet Options and Choose Security Tab
    Select the Zone to modify and Press Custom level
    Find Enable XSS filter Setting - Select Disable and click Ok
    !ENTRY oracle.oats.scripting.diagnosisTool.api.DiagnosisExecutor 4 0 2012-07-09 17:08:52.594
    !MESSAGE Failure found when diagnosing Oracle EBS/Forms Load Testing Forms LT Diagnoser
    !ENTRY oracle.oats.scripting.diagnosisTool.api.DiagnosisExecutor 4 0 2012-07-09 17:08:52.594
    !MESSAGE Did not auto-fix the problem.
    !ENTRY oracle.oats.scripting.diagnosisTool.api.DiagnosisExecutor 4 0 2012-07-09 17:08:52.594
    !MESSAGE Suggestion for fixing: Please change your Java proxy setting to Use Browser Settings
    Aprreciate help on this.

    To resolve this, you need to reconfigure the "Oracle Application Testing Suite Helper Service" (OATSHelperSvr) to start as a user who has privledges to run open script tests rather than the default SYSTEM user.
    Reconfiguring the OATSHelperSvr Service:
    1. Open the services panel (Start > Run > services.msc)
    2. Find the Oracle Application Testing Suite Helper Service
    3. Right Click > Properties then select the Log On Tab
    4. Specify an interactive user that has rights to run OpenScript (test by logging in as that user and running tests):
    5. Click OK
    6. Restart the service after dialogs are closed by Right Click > Restart
    7. You should now repeat this process for the "Oracle Application Testing Suite Agent Service" (eLoadAgentMon) Service (Two services in
    total)
    You should now retry running the test in Oracle Test Manager

  • TS3297 itunes 10.6.1 now asking for 3 security questions. After input I get "error in the itunes store -1202". I cannot purchase from the store.

    Running Vista Ultimate. Itunes 10.6.1 is now asking to answer 3 security questions before accessing the store. After entry I get "error in the itunes store -1202" I cannot purchase music at this point. Any help is appreciated.

    This problem is resolved. I deleted the old iTunes (with write permissions turned on for my account) and reinstalled successfully. Removing the deleted iTunes from Trash was troublesome even with root but after playing around with permissions and flags, I was able to remove it.

  • HT201210 Trying to restore ipod and keep on getting error message: the ipod software update server could not be contacted. the network connection was reset

    Hello can someone please help? Trying to restore ipod and I keep on getting error message: The IPod software update server could not be contacted. The network connection was reset. Make sure your network is active and try again.

    Try:
    - Powering off and then back on your router.
    - iTunes for Windows: iTunes cannot contact the iPhone, iPad, or iPod software update server
    - Change the DNS to either Google's or Open DNS servers
    Public DNS — Google Developers
    OpenDNS IP Addresses
    - Try on another computer/network
    - Wait if it is an Apple problem

  • Getting Error In the Routine - While writing Code for the Cross Reference.

    Hi,
    Getting Error In the Start Routine - While writing Code for the Cross Reference from the Text table ( /BIC/TZMDES with Fields /BIC/ZMDES(Key),TXTSH ) Getting Error as [ E:Field "ZMDES" unknown ].
    Transformation : IOBJ ZPRJ3(Source) -> IOBJ ZPRJC ( Target ).
    The Source  Fields are: 0logsys(Key),zprj3(Key),ZDOM3.
    The Target Fields are : 0logsys(Key),zprjc(Key),ZDOM3, UID.
    Here i am trying to Update the target Field UID by Comparing the Source Field [ zprj3(Key)] with the Text table ( /BIC/TZMDES ) and update the UID.
    The Code is as below:
    Global Declarations in the Start Routine:
    Types: begin of itabtype,
            ZMDES type /BIC/TZMDES-/BIC/ZMDES,
            TXT type /BIC/TZMDES-TXTSH,
             end of itabtype.
    data : itab type standard table of itabtype
    with key ZMDES,
    wa_itab like line of itab.
    Routine Code :
    select * from /BIC/TZMDES into corresponding fields of table itab for
    all entries in SOURCE_PACKAGE
    where ZMDES = SOURCE_PACKAGE-/BIC/ZPRJ3.
    READ TABLE itab INTO wa_itab
    WITH KEY ZMDES = SOURCE_PACKAGE-/BIC/ZPRJ3
    BINARY SEARCH.
    IF SY-SUBRC = 0.
    RESULT = wa_itab.
    CLEAR wa_itab.
    The tys_SC_1 structure is :
    BEGIN OF tys_SC_1,
         InfoObject: 0LOGSYS.
            LOGSYS           TYPE RSDLOGSYS,
         InfoObject: ZPRJ3.
            /BIC/ZPRJ3           TYPE /BIC/OIZPRJ3,
         InfoObject: ZDOM3.
            /BIC/ZDOM3           TYPE /BIC/OIZDOM3,
         Field: RECORD.
            RECORD           TYPE RSARECORD,
          END   OF tys_SC_1.
        TYPES:
          tyt_SC_1        TYPE STANDARD TABLE OF tys_SC_1
                            WITH NON-UNIQUE DEFAULT KEY.
    Please suggest with your valuable inputs.
    Thanks in Advance

    I have split the code in two.. one for start routine.. other for field routine.. hope this helps
    Types: begin of itabtype,
    ZMDES type /BIC/TZMDES-/BIC/ZMDES,
    TXT type /BIC/TZMDES-TXTSH,
    end of itabtype.
    data : itab type standard table of itabtype
    with key ZMDES,
    wa_itab like line of itab.
    Start routine
    select * from /BIC/TZMDES into corresponding fields of table itab for
    all entries in SOURCE_PACKAGE
    where ZMDES = SOURCE_PACKAGE-/BIC/ZPRJ3.
    Sort itab.
    field routine
    CLEAR wa_itab.
    READ TABLE itab INTO wa_itab
    WITH KEY ZMDES = SOURCE_FIELD-/BIC/ZPRJ3
    BINARY SEARCH.
    IF SY-SUBRC = 0.
    RESULT = wa_itab-<field name>

  • Adobe reader (11.3.2) PDF's on ipad and getting error that the file is corrupt!!

    i have the latest Adobe reader from the app store (11.3.2) however i am struggling to open PDF's on ipad and getting error that the file is corrupt!!
    any help or suggestions welcome

    Would you describe how you transferred the PDF file to your iPad and iPhone?  Did you send it as an email attachment and open it on your iPad and iPhone?
    The file may have been corrupted by Apple Mail, which is a known problem.  Please see Problem #1 in the FAQ document How to avoid known PDF email attachment problems.
    Would you try some experiments so that we can troubleshoot the problem?  During the experiments, please use cloud storage (e.g. Acrobat.com, Dropbox, Google Drive, etc.) and avoid sending the PDF file as an email attachment.
    Rename the corrupted/damaged PDF file on your iPad.  For example, add "_damaged.pdf" to the file name.
    Upload the corrupted/damaged PDF file to the cloud storage of your choice.
    Download the corrupted/damaged PDF file from the cloud storage to your Windows or Mac desktop computer.
    Open it in the desktop version of Adobe Reader XI for Windows or Mac.
    Does Adobe Reader XI on your desktop computer display an error message?
    Upload the (good) PDF file on your iPhone to the cloud storage.
    Download the (good) PDF file from the cloud storage to your iPad.
    Open it in Adobe Reader on your iPad.
    Does Adobe Reader on your iPad display an error message?
    We can investigate further based on what you will find.
    Thank you for your help.

  • I am trying to activate new itunes card. I am getting error message: The code you have entered has not been properly activated. Does this mean the store did something wrong or me?

    I am trying to activate new itunes card. I am getting error message: The code you have entered has not been properly activated. Does this mean the store did something wrong or me?

    Yes, the store didn't properly activate the card. If the store is nearly then you could try going back and asking them to do so, if it isn't (or if they can't/won't help) then try contacting iTunes Support (you will probably need to give them images of the front and back of the card, and possibly its receipt) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then iTunes Cards And Codes

Maybe you are looking for

  • 1st generation ipod touch no wifi

    My friend and I both have a first generation ipod touch with version 3.1.3. He lost his wifi completely after installing a few apps. Recently I turned mine on for the first time in a while, and I now I can't pick up any wifi at all either...Anywhere.

  • How to enable "Enable Disk Use" function on itunes 10.7

    I can't find function ENABLE DISK USE in my itines version. Before it was in OPTIONS, but not I don't know where to look. Help please

  • How to have my dial up connection added to the network utility program?

    how to have my dial up connection added to the network utility program for monitoring? though i am connected by dial-up, the connection is not monitored by the utility program. the drop down box there does not show the modem at all. ?

  • Searching in an Array

    Im trying to write a method that will take a string parameter and see if that string is in an Object array or not.... but a variable test never change..... the second method suppose to return the index of that name in an array... but it alway -1... c

  • Blackberry Curve 8300, how to download AIM & MSN

    I have recently got a used blackberry curve from a friend of mine, and I would like to download AIM & MSN but when i tried to download them i got a message saying my device didnt support the software.  If anybody knows a way i can get these downloade