The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Copying a file into a vector?

Posted by zxcmnb on October 11, 2001 at 8:32 AM

Hi all. I am trying to read the contents of a text file into a vector, but am having some grief. My method for reading the file and a sample of the contents of the file are below. Can someone point me in the right direction with this? Thanks heaps.

Vector inventory = new Vector();

public void readFile() {
try {
SimpleReader inFile = new SimpleReader("Invent.txt");
while (!inFile.EOF()) {
String inventory = inFile.getString();
} catch (FileNotFoundException e) {
System.err.println("File Not Found");
} catch (IOException e) {


Sample of the contents of Invent.txt
01::Juice Berri Orange 2 lt ::2.85::26
02::Juice Berri Orange 4 lt ::4.45::45
03::Juice Berri Orange&Mango 2lt ::2.65::65
04::Juice Berri Orange&Mango 4lt ::4.40::32
05::Juice Berri Grapefruit 2lt ::2.98::45


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us