• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reading a text file records separated by a ';'

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,



Just got stuck ,how to read a text file which has addresses separated by ';' and store the content in another text file

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read the lines from the text file and parse each line using String.split(";") to separate each token
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.
An alternative would be to use a Scanner with ";" as its delimiter. Obviously if there are any semicolons in the wrong place the file will behave as a corrupted file.
 
shield kumar
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Welcome to JavaRanch.
An alternative would be to use a Scanner with ";" as its delimiter. Obviously if there are any semicolons in the wrong place the file will behave as a corrupted file.



i never used this Scanner can you write simple sample code that will read the address from a text file separated by ";"
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

punit pandia wrote:i never used this Scanner can you write simple sample code that will read the address from a text file separated by ";"



Why don't you try it yourself first, and see if it works. If not, post your code, explain exactly what it does, and we can help you fix it.

The best way to learn it to try it yourself.
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you can, have a look at the API documentation, give it a go and come back with any questions you might have!
 
reply
    Bookmark Topic Watch Topic
  • New Topic