Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException at Split()

  1. #1
    Member
    Join Date
    Sep 2012
    Location
    The Netherlands
    Posts
    84
    My Mood
    Inspired
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException at Split()

    I have a small program that works fine on most files.
    But since I try to read this incredible huge tab sperated file it gives me after a while an java.lang.ArrayIndexOutOfBoundsException at an split function.

    Can this also be becasue the file is too big and my computer here doesn't have enough memory?
    Becasue when running this almost the max. in memory is used. (I do not have much memory on this computer I am now on...)

    Becasue all the program realy does is reading the file and printed the split data to a new file. :S


  2. #2
    Junior Member
    Join Date
    May 2012
    Location
    Hyderabad,Vizag
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException at Split()

    means you are splitting a string object without having any data.

    Example:-

    String mainString = "";

    String splitStringArray[] = mainString.split("some Character");

    if you use statement like splitStringArray[0],splitStringArray[1],splitStringArray[2].....;

    then you can get Exception like ArrayIndexOutOfBounds

  3. #3
    Member
    Join Date
    Sep 2012
    Location
    The Netherlands
    Posts
    84
    My Mood
    Inspired
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException at Split()

    Okey.
    The problem also with this file is, it is so big that I can hardly open it so I can't look in it.

    Is there maybe a way that I can say
    if "" do don't split, else split().

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException at Split()

    The String class has methods you could use to test for empty
    Or test the length of the array returned by split() to see if it has any elements (length > 0)
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Sep 2012
    Location
    The Netherlands
    Posts
    84
    My Mood
    Inspired
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException at Split()

    I will try that length item.

    Thanks.

Similar Threads

  1. Exception in thread "main" java.lang.NullPointerException problem.......
    By Adam802 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 20th, 2012, 02:23 AM
  2. Replies: 3
    Last Post: December 7th, 2011, 02:03 AM
  3. Replies: 6
    Last Post: November 12th, 2010, 04:40 AM
  4. Replies: 2
    Last Post: March 26th, 2010, 11:22 AM
  5. Replies: 1
    Last Post: October 25th, 2009, 11:54 AM