Win a copy of Terraform in Action this week in the Cloud 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

removing multiple ocurences in a string

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic