このコードはクライアントを検出できますが、削除できません。クライアント名 - "rafael" 私はちょうどクライアントを取り除くことができません。なぜ、私はいくつかのコードを試しましたが、didntの仕事を試しました。ファイルからユーザーを削除する方法
//これはクライアントにあなたがリストをイテレータイテレータを使用する必要が
public void EliminarUtilizador(){
ArrayList<ArrayList<String>> dados = new ArrayList<ArrayList<String>>();
dados = _ficheiro.lerDados();
// the line is an array that haves date stored on the file
//0-nome 1-pass ...
for(ArrayList<String> linha : dados){
Utilizador a = new Utilizador(linha);
if("Rafael".equals(linha.get(0))){
System.out.println("Client found");
}
}
}
----------------------
//This reads the file
public ArrayList<ArrayList<String>> lerDados(){
ArrayList<ArrayList<String>> dados = new ArrayList<ArrayList<String>>();
Scanner s;
try{
s = new Scanner(new File(nomeFicheiro));
}catch(FileNotFoundException e){
return dados;
}
String dado;
while(s.hasNextLine()){
dado = s.nextLine();
dados.add(new ArrayList<>(Arrays.asList(dado.split(","))));
}
s.close();
return dados;
}
*いくつかのコードを試しましたが、試したコードはどこですか?なぜそれは動作しませんでした。確かにファイルに書き込む必要があります。あなたは30分前に同じ質問を書いていませんでしたか? –
削除するコードがわからない、私はdados.remove linha.removeなどを試した –
ファイルに書き込む方法を検索 –