Parse .txt directly into Arraylist
in
Programming Questions
•
1 year ago
I am parsing some numerical values from a .txt file to an arraylist. Right now i'm doing that like this:
- // create arraylist
- ArrayList values = new ArrayList();
- // load values into temporary int array
- int[] v = int(loadStrings("values.txt"));
- // copy contents of temporary int array to arraylist
- for (int i=0; i<v.length; i++) {
- values.add(v[i]);
- }
- println(values.size());
1