import java.io.*;
import java.util.ArrayList;
public class Account {
private String username;
private String password;
private static ArrayList<Account> accounts = new ArrayList<Account>();
private String authority;
public static ArrayList<Account> getAccounts() {
return accounts;
}
public static void setAccounts(ArrayList<Account> accounts) {
Account.accounts = accounts;
}
public Account() {
}
public Account(String authority) {
this.setAuthority(authority);
try {
readUser();
} catch (IOException e) {
e.printStackTrace();
}
}
public String getAuthority() {
return authority;
}
public void setAuthority(String authority) {
this.authority = authority;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void readUser() throws IOException {
FileInputStream fileInputStream = null;
if (getAuthority().equals("管理员")) {
fileInputStream = new FileInputStream("./lib/teacher.txt");
} else if (getAuthority().equals("学生")) {
fileInputStream = new FileInputStream("./lib/student.txt");
}
BufferedReader br = new BufferedReader(new InputStreamReader(fileInputStream));
String line;
while ((line = br.readLine()) != null) {
String[] arr = line.split("\\s+");
Account account = new Account();
account.setUsername(arr[0]);
account.setPassword(arr[1]);
accounts.add(account);
}
setAccounts(accounts);
br.close();
fileInputStream.close();
}
}
最近下载更多
wanglinddad LV55
2024年3月9日
fenghuijun LV26
2024年1月13日
计算机暴龙战士 LV19
2024年1月5日
305865088 LV8
2023年12月15日
Seaskye LV14
2023年11月28日
2410068425 LV23
2023年11月27日
最代码官方 LV168
2023年11月26日
最近浏览更多
微信网友_7660121999364096
8月30日
暂无贡献等级
ddman9009 LV25
7月4日
Hhuu88
6月16日
暂无贡献等级
120_wu LV4
2024年12月3日
yimaoermao LV1
2024年11月28日
微信网友_6234675614470144 LV1
2024年10月28日
Peny_ZH LV5
2024年9月20日
thsgli LV9
2024年8月21日
hmf1989
2024年7月25日
暂无贡献等级
zzs269285304 LV7
2024年7月17日

