import java.io.*; import java.util.Vector; public class LoadFromFile { private Vector v; LoadFromFile(String d, String f) {//Constructor try{ File input = new File(d, f); /* Create reader stream to open and read the file. The tokenizer stream parses the file into integer tokens, ignoring whitespace characters and comma's */ final StreamTokenizer stream = new StreamTokenizer(new BufferedReader(new FileReader(input))); stream.whitespaceChars(',',','); //can seperate by comma int token; final StreamTokenizer streamagain = new StreamTokenizer(new BufferedReader(new FileReader(input))); v = new Vector(); //initialize Vector to hold integers //this loop loads the arra from the input file while((token = streamagain.nextToken()) != streamagain.TT_EOF) { switch(token) { case StreamTokenizer.TT_NUMBER: Integer u = new Integer((int)streamagain.nval); v.addElement(u); break; default: break; } }//while loop } //try catch(FileNotFoundException e) { System.err.println(e); return; } catch (IOException e) { System.err.println("Error reading input file" +e); return; } } Vector GetData() { return v; } }