[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

Adding new objects to Vector

public static void main(String [] args)
{
// The empty vector that will be used to store accounts
Vector accountVector = new Vector();
}

// New class methods
// public is missing so that it can remain in this file.
class inOut
{
      private static String line;
      private static String txtFileIn = "account.txt";
      static BufferedReader a = null;
      static StringTokenizer theStrings;
      static boolean done = false;

      public static void readInAccounts(Vector accountVector)
      {
            // reads text file for input
            try
            {
                  FileInputStream b = new FileInputStream(txtFileIn);
                  a = new BufferedReader(new InputStreamReader(b));
            }

            // exceptions omitted
                line = a.readLine()
      accountVector.add(line);
}

Will this line of thought add the current line being read in a file as an object in a vector?

If not how should I be thinking?
0
smkJackstraw
Asked:
smkJackstraw
1 Solution
 
objectsCommented:
yes, it will read the first line of the file
use a loop if you'd like to read more
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now