Hello LabX and welcome to the Java Programming Forums
Does this work as expected?
import java.util.*;
import java.io.*;
public class People {
static ArrayList<String> Users = new ArrayList<String>();
public static void main(String[] args) {
try {
File file1 = new File("people.txt");
Scanner Filereader1 = new Scanner(file1);
while (Filereader1.hasNextLine()) {
int i = 0;
String Name = Filereader1.next();
Users.add(i, Name);
i++;
}
Object[] elements = Users.toArray();
for (int a = 0; a < elements.length; a++) {
System.out.println(elements[a]);
}
}
catch (FileNotFoundException e) {
System.out.println("error" + e);
}
}
}