|
From: Wildern t. S. <tim...@ya...> - 2002-04-26 14:58:46
|
This is getting annoying... I don't know why this was truncated
the first time I posted it.
boolean isValidName(String strName)
{
if (strName == null)
return false;
if (strName.equals("")
|| strName.length() > namecap
|| strName.toLowerCase().equals("god")
|| strName.toLowerCase().equals("default"))
return false;
String strValid = "0123456789][_'#";
char[] letters = strName.toCharArray();
char[] validChars = strValid.toCharArray();
for(int n=0; n<letters.length;n++)
{
if (!Character.isLetter(letters[n]))
{
for(int i=0; i<validChars.length;i++)
{
if (letters[n] != validChars[i])
return false;
}
}
}
RandomAccessFile rafFile = null;
try
{
String strDirtyWord;
String strLowerCaseName = strName.toLowerCase();
rafFile = new RandomAccessFile("conf/dirtyWordFile",
"r");
strDirtyWord = rafFile.readLine();
while (strDirtyWord != null)
{
if (strLowerCaseName.indexOf(strDirtyWord) != -1)
{
rafFile.close();
return false;
}
strDirtyWord = rafFile.readLine();
}
rafFile.close();
}catch (Exception e)
{
System.out.println(strName + " had an error checking for
bad name in isBadName():"+e.toString());
return false;
}
return true;
}
__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/
|