Best Method to Write ArrayLists
-
I don't find a suitable method to write ArrayLists to a text file. Does each attribute of the class objects that make up the ArrayList have to be written separately? When I wriye the class object of the ArrayList, it just writes out the memory location. Any advice would be much appreciated. Thank you.
AF Pilot
-
I don't find a suitable method to write ArrayLists to a text file. Does each attribute of the class objects that make up the ArrayList have to be written separately? When I wriye the class object of the ArrayList, it just writes out the memory location. Any advice would be much appreciated. Thank you.
AF Pilot
you have to loop through the array list and get each array and print it through loop two for example
private void printArryList(ArrayList<string[]>someList)
{
int counter=0;
for (int i = 0; i < someList.size(); i++) {
System.out.print("["+(++counter)+"]");
for (int j = 0; j < someList.get(i).length; j++) {
System.out.print(someList.get(i)[j]+" ");
}
System.out.println();
}
} -
you have to loop through the array list and get each array and print it through loop two for example
private void printArryList(ArrayList<string[]>someList)
{
int counter=0;
for (int i = 0; i < someList.size(); i++) {
System.out.print("["+(++counter)+"]");
for (int j = 0; j < someList.get(i).length; j++) {
System.out.print(someList.get(i)[j]+" ");
}
System.out.println();
}
}Thank you very much. I couldn't find much about writing out an ArrayList to a file in any of the Java documentation or tutorials (that appeared understandable to me, anyway). Much appreciated.
AF Pilot