This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

removing multiple ocurences in a string

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello ranchers

i am coding a method that recieves an arraylist as a parameter, in it there are multiple rows of string in this format: data1;data2;data3;.....datan;
i need to parse each row of the list in order to get every single data item in it so i can then build an excel sheet with this data but that's another story what i cannot seem to do propertly is the correct parsing of the string can anyone help me?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when you say excel, do you mean excel-like, as in JTable?
if so,
you can use String.split() for each line, to return a String[]
the String[] can be used as an argument for a vector (Collection)
this vector is then added to another vector

once you have all your data read in, the vector of vectors
is the 'row' argument for the TableModel of the JTable
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, welcome to the ranch!

Is there any chance your data can have a semi-colon in it? What would that look like? Some escape mechanisms can make this a little harder.

BTW: If you just change all the semi-colons to tabs and write it back to disk, Excel will open it right up.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!