flint0131
03-07-2010, 11:11 AM
public boolean is_uNameRegistered ( String n ) {
FileInputStream fin;
StringTokenizer tokz;
String dbaseStr;
try {
String op = "";
fin = new FileInputStream("uName_db.txt");
dbaseStr = new DataInputStream(fin).readLine();
tokz = new StringTokenizer(dbaseStr);
while ( tokz.hasMoreTokens() ) {
op = tokz.nextToken();
if ( op.equals(n) ) {
return true;
}
}
fin.close();
return false;
} catch ( IOException e ) {
statusTxt.setText("Unable to read from databse.");
}
return false;
}
public boolean is_pWordRegistered ( String n ) {
FileInputStream fin;
StringTokenizer tokz;
String dBaseStr;
try {
String op = "";
fin = new FileInputStream("pWord_db.txt");
dBaseStr = new DataInputStream(fin).readLine();
tokz = new StringTokenizer(dBaseStr);
while ( tokz.hasMoreTokens() ) {
op = tokz.nextToken();
if ( op.equals(n) ) {
return true;
}
}
fin.close();
} catch ( IOException e ) {
statusTxt.setText("Unable to read from database.");
}
return false;
}
I'm trying to compare two strings, the input from the user and the one that is stored on my .txt file ( used as my database ). The problem is it always return as false.
I have this code :
if ( both functions above are true ) {
// some codes
} else {
// prompts incorrect password
}
it always "Incorrect Password".. DDD: somebody help? or suggest another solution?
FileInputStream fin;
StringTokenizer tokz;
String dbaseStr;
try {
String op = "";
fin = new FileInputStream("uName_db.txt");
dbaseStr = new DataInputStream(fin).readLine();
tokz = new StringTokenizer(dbaseStr);
while ( tokz.hasMoreTokens() ) {
op = tokz.nextToken();
if ( op.equals(n) ) {
return true;
}
}
fin.close();
return false;
} catch ( IOException e ) {
statusTxt.setText("Unable to read from databse.");
}
return false;
}
public boolean is_pWordRegistered ( String n ) {
FileInputStream fin;
StringTokenizer tokz;
String dBaseStr;
try {
String op = "";
fin = new FileInputStream("pWord_db.txt");
dBaseStr = new DataInputStream(fin).readLine();
tokz = new StringTokenizer(dBaseStr);
while ( tokz.hasMoreTokens() ) {
op = tokz.nextToken();
if ( op.equals(n) ) {
return true;
}
}
fin.close();
} catch ( IOException e ) {
statusTxt.setText("Unable to read from database.");
}
return false;
}
I'm trying to compare two strings, the input from the user and the one that is stored on my .txt file ( used as my database ). The problem is it always return as false.
I have this code :
if ( both functions above are true ) {
// some codes
} else {
// prompts incorrect password
}
it always "Incorrect Password".. DDD: somebody help? or suggest another solution?