• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Split using tab delimeter

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to split text of file on tab delimiter and then store those values in different variables. I am getting error "java.lang.ArrayIndexOutOfBoundsException: 1". Below is the code I am using.
Also when I use the same code to split another file on come delimiter it works absolutely fine.


   }
Screenshot-2017-11-27-23.50.14.png
[Thumbnail for Screenshot-2017-11-27-23.50.14.png]
 
Saloon Keeper
Posts: 9284
78
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On line 6 you want to call  nextLine(), not next(). And on line 5 call hasNextLine().

By calling next() you were only getting just the text between two sets of white-space characters (e.g. '\t') thus stripping out the tabs so there were no tabs left to split() on.
 
ss chaudry
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much. It worked
 
First, you drop a couch from the plane, THEN you surf it. Here, take this tiny ad with you:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic