vector not storing objects properly,
hi,
i'm reading a file using a stringtokenizer, to parse it, and storing the read content into a vector, but when i display the vector's contents, they seem to be out of place. here is the code:
import java.io.*;
import java.util.*;
class ReadFile{
publicstaticvoid main(String args[]){
Vector programs =new Vector(4);
programs.add(0,null);
programs.add(1,null);
programs.add(2,null);
programs.add(3,null);
String text;
String programLink;
String programName;
try{
BufferedReader br =new BufferedReader(new FileReader("progList.txt"));
text = br.readLine();
while (text !=null){
StringTokenizer strToken =new StringTokenizer(text,",");
programLink = strToken.nextToken();
System.out.println(programLink);
programName = strToken.nextToken();
System.out.println(programName);
if(programName.equals("Microsoft Word")){
programs.add(0,programLink);
}
if(programName.equals("Microsoft Excel")){
programs.add(1,programLink);
}
if(programName.equals("Microsoft Outlook")){
programs.add(2,programLink);
}
if(programName.equals("Microsoft PowerPoint")){
programs.add(3,programLink);
}
text = br.readLine();
}
}catch(FileNotFoundException e){
System.out.println("File not found: " + e);
}catch(IOException e){
System.out.println("IOException found: " + e);
}
for(int i = 0; i < 4; i++){
System.out.println("Item at location " + i +" is " + (String)programs.elementAt(i));
}
}
}
the file looks like:
C:\WIN98_SE\start menu\programs\Acrobat Reader 5.0.lnk,Acrobat Reader 5.0
C:\WIN98_SE\start menu\programs\Microsoft Excel.lnk,Microsoft Excel
C:\WIN98_SE\start menu\programs\Microsoft Outlook.lnk,Microsoft Outlook
C:\WIN98_SE\start menu\programs\Microsoft Word.lnk,Microsoft Word
C:\WIN98_SE\start menu\programs\Microsoft PowerPoint.lnk,Microsoft PowerPoint
C:\WIN98_SE\start menu\programs\MSN Messenger.lnk,MSN Messenger
if you run it you'll see that it adds Word and PowerPoint ok, but not the others, but i can't figure out where it's storing them incorrectly.
Thanks.

