packagecom.mingrisoft;importjava.io.BufferedReader;importjava.io.FileReader;importjava.io.IOException;importjava.util.Scanner;publicclassLookUp{publicstaticintmain(String...
package com.mingrisoft;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
public class LookUp {
public static int main(String[] args)
{
String line = null;
//String key = null;
String filePath = "g:\\exercise\\library\\db_operator.txt";
System.out.print("\n请输入旧密码:");
Scanner scanner = new Scanner(System.in);
String passWordOld = scanner.nextLine();
try
{
BufferedReader br = new BufferedReader(new FileReader(filePath));
line = br.readLine();//跳过第一行
int j = 0;
while((null != line)&&(line.startsWith("曾一洲")))
{
String[] ch = line.split("\\t");//按正则表达式拆分字符串
for(int i = 0;i <= ch.length;i++)
{
if(" " == ch[i])
continue;
else if(j == 3)
{
if(ch[i] == passWordOld)
{
System.out.print("\n密码正确!");
break;
}
else
{
System.out.print("\n密码错误!");
return 0;
}
}
else
j++;
}
j = 0;
br.close();
}
br.close();
} catch (Exception e)
{
System.out.println("IOException!");
}
return 1;
}
}
展开