• 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

need to delimit string to get into parts  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've currently setup the code



and it reads in the text file fine, but I need to be able to delimit my input into two strings based on the ; that appears in the line. Here is my current print out

21806000300231;5847
21806000327226;
21806000273164;114
21806000274170;8245
21806000334313;
21806000115043;4220
21806000403274;1313

and i need to read each number into a string array separately so that i have something like

string[1] = 21806000300231
string2[1] = 5847


i've searched for some example code, but haven't ran across any yet.

thanks
 
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use split() function

Example
 
Marshal
Posts: 62239
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by sudhir nim:
You can use split() function.

But always check here
that you are not using a metacharacter in your split() argument. I think ; is a normal character.
 
Sheriff
Posts: 21557
100
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this case the CSV file can be read using split(), but for more complex files, where the values can contain ; as well, I'd suggest opencsv.
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!