I need to read a file with this format:
[user1, user2, user3]
Then I need to store it in an ArrayList. I have no idea about reading files and so..
Thanks for the help and sorry for my bad english :)
I need to read a file with this format:
[user1, user2, user3]
Then I need to store it in an ArrayList. I have no idea about reading files and so..
Thanks for the help and sorry for my bad english :)
Okay guys, I wrote some code and I got this:
public static String getGroups(int index) {
try {
for (int i = 0; i < countLines(); i++) {
String[] content = new String[countLines()];
File file = new File(getIndexValues(i, 1));
try {
FileReader reader = new FileReader(file);
char[] chars = new char[(int) file.length()];
reader.read(chars);
content[i] = new String(chars);
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
return content[index];
}
} catch (IOException ex) {
Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
It returns all the content in the file I want. I have a list of files so if I type getGroups(0) it will take the first line of the index file and will look for it's path to load it.
Now, how can I put the output in an ArrayList? I need to load it in a JList.