java - How do I read multiple file lines and store them into different Objects Using Scanner -


i have file trying read multiple lines from. depending if realtor line or property line, store things line values array. cant figure out proper loop read lines here code reading lines

    while (filescanner.hasnextline()) {         string oneline;         string[] linevalues = null;         oneline = filescanner.nextline();          linevalues = oneline.split(",");          if (linevalues[0].contains("realtor")) {             if (linevalues[1].contains("add")) {                                     processrealtoraddition(linevalues);                                 } else if (linevalues[1].contains("del")) {                 realtordeletion(linevalues);             }             else                 break;          }  if (linevalues[0].contains("property")) {             system.out.println("fsdfsdfsdfdsfdsfsdfsdfds");                             if (linevalues[1].contains("add")) {                                     processpropertyaddition(linevalues);                 break;             } else if (linevalues[1].contains("del")) {                 propertydeletion(linevalues);             }         }                  } } 

but when run this:

the realtor object license number of mn4564567 has been added fsdfsdfsdfdsfdsfsdfsdfds realtor log:

property log: property{mlsnumber=4455667, licensenumber=mn4564567, streetadress=4455 circle, city=denver, state=co, zipcode=80333, bedrooms=1, bathrooms=1.0, sold=false, askingprice=344555.0} properties correct build successful (total time: 0 seconds)

this file i'm trying read:

realtor,add,mn4564567,carla,combs,444-555-6666,0.014 property,add,4455667,mn4564567,4455 circle,denver,co,80333,1,1,n,344555 realtor,add,rr6655443,jerry,smith,555-444-3333,0.013 property,add,23456789,rr6655443,888 terry lane,longmont,co,80503,3,2,n,222222 realtor,add,ab1234567,matthew,munez,123-456-7890,0.012 property,add,1234567,ab1234567,1234 way,somewhere,co,82222,3,3,y,222222 property,add,2234567,ab1234567,345 main st,fort collins,co,81333,4,3.5,n,222333 realtor,del,mn4564567 realtor,add,xy98765432,alex,yung,999-888-7777,0.013 property,add,9998888,xy98765432,111 main st,cheyenne,wy,82222,1,1

,n,199888

i need read first line right info, start while loop on again read second line. thanks!

this static method process addition

static void processpropertyaddition(string linevalues[]) {     property property = new property(linevalues);      boolean value1 = property.verifymlsnumber();     boolean value2 = property.verifystate();     boolean value3 = property.verifyzipcode();      if (value1 == false) {         system.out.println("error: invalid mls number: "                 + property.mlsnumber + "\n");     } else if (value2 == false) {         system.out.println("error: invalid state: "                 + property.state + "\n");     } else if (value3 == false) {         system.out.println("error: invalid zip code: "                 + property.zipcode + "\n");     }      boolean value4 = realtorlogimpl.islicenseunique(property.getlicensenumber());      boolean value5 = propertylogimpl.ismlsunique(property.getmlsnumber());     if (value4 == false && value5 == false) {         propertylist.add(property);     } else if (value5 == true && value4 == true) {         propertylist.add(property);     } else if (value4 == false && value5 == true) {         propertylist.add(property);          system.out.println("the property realtor license number "                 + property.getlicensenumber() + " , mls number"                 + property.getmlsnumber() + " has been added");     } else if (value4 == true && value5 == false) {         system.err.println(" property not added due "                 + "a realtor license or mls number not "                 + "unique");     } } 

this method of propertylogimpl add property property linked list

  public boolean add(property property) {     return propertylist.add(property); } 

i have have method add property, feel method may incorrect , may cause of it

instead of this

 }  if (linevalues[0].contains("property")) { 

you wanted write

 } else if (linevalues[0].contains("property")) { 

also whenever use contains probaly wanted use equals instead.

and mentioned in comments usage of break statements suspicious.

if run infinite loop, there nothing in code shown far cause this. possible infinite loop comes here:

realtorlogimpl.islicenseunique(property.getlicensenumber()); 

it should easy find cause debugger (hint, hint, ...)


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -