• Post Reply Bookmark Topic Watch Topic
  • New Topic

need help

 
kavins
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am creating andwriting to a file which has the following contents:
Kavin*1101 new hampshire ave*
where "Kavin" is the user id and the other is the address.
There are many such user id's with there corresponding addressess
I want to write a getAddress() function which will give me the corresponding address for the user id entered.
Also while writing ro the file,if the user id is repeated then override it with the new address.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kavin- please take a look at our display name policy and edit your display name to include a first and last name. Thanks.
For your question - what have you tried so far? Can you read lines from a file? Once you've read a line, you can isolate the address field using something like:
int firstAsterisk = line.indexOf("*");
int secondAsterisk = line.indexOf("*", firstAsterisk);
String address = line.substring(firstAsterisk + 1, secondAsterisk);
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!