• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with file reading  RSS feed

 
Donatas Latauskas
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem when reading information from file. I have for example such a structure of file1:
Lastname \t Adress \t WorkName \t Date \t HoursWorked
I do the reading like this:



This code ok. It reads the file and everything is perfect. But I want to have 'adresas' not just "LongStreet5" but "Long Street 5", so if I do so, I get an error, because it reads the next object if it detects one SPACE. How to do the turning to the next object not after one SPACE, but after one TAB. Or what else I can do to have an opportunity to write smth like "Long Street 5"?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use \t as your delimiter character
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, first off: did you read the Javadocs for StringTokenizer? Pay close attention to the constructor that takes two arguments.

But secondly, StringTokenizer is kind of old-fashioned: there are better ways to do things in recent JDKs. Look at the "split()" method in the String class.
 
Donatas Latauskas
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!