i using amazon web services s3, , using to, - open connection (working fine) - open input stream text file has usernames , passwords listed username,password username,password ... works fine, run issues when trying check if username matches password.
take look,
while (infinite == 1) { system.out.println("ran"); if (trytologin == true) { system.out.println("ran2"); trytologin = false; bufferedreader br = new bufferedreader(new inputstreamreader(object.getobjectcontent())); string linevalue = null; while((linevalue = br.readline()) != null && loggedinas == null){ string splitresult[] = linevalue.split(","); if ("saucymeatman" == splitresult[0] && "mufasa" == splitresult[1]) { loggedinas = splitresult[0]; system.out.println("logged in"); //ui.usernamelogin.gettext() } else { system.out.println("split 0 : " + splitresult[0]); system.out.println("split 1 : " + splitresult[1]); } } } }
even though "saucymeatman" == splitresult[0] && "mufasa" == splitresult[1] not print "logged in" or set loggedinas anything. sure splitresult[0] equals "saucymeatman" because prints "split 0 : saucymeatman".
thanks in advance.
do not use ==
compare string values; use equals
method of string
class. ==
operator compares objects references determine if refer same object; doesn't compare string contents.
Comments
Post a Comment