package daoimport scala.collection.mutable.ListBufferclass UserDAO {def loadUsers(): ListBuffer[UserModel] = {val users = new ListBuffer[UserModel]()val source = scala.io.Source.fromFile("users.txt")for (line <- source.getLines()) {val Array(username, password, role) = line.split(",")// 实例化一个用户,保存到Listusers += UserModel(username, password, role)}// 关闭连接source.close()users } }