The following code is intended to pull in a file's contents, load into a vector, and print the output to the screen by unloading the vector through the iterator. Unfortunately, I am getting abstract class error messages every time I use the iterator. Here is the code:
private void jButton4MouseClicked(java.awt.event.MouseEvent evt) {
// Add your handling code here:
try{
iFile = new File(openFilePath);
BufferedReader fIn = new BufferedReader(new FileReader(iFile));
oFile = new File(saveFilePath);
// BufferedWriter fOut = new BufferedWriter(new FileWriter(oFile));
Vector svector = new Vector();
Iterator isiterator = svector.iterator();
String line = fIn.readLine();
while(line!= null)
{
svector.add(line);
line = fIn.readLine();
}
int vecsize = svector.size();
System.out.println(vecsize);
fIn.close();
while(isiterator.hasNext())
System.out.print(isiterator.next());
}
catch (IOException e)
{
System.out.println(openFilePath + " cannot be opened."
}
}
Can anyone tell me what is wrong here. I used iterators and vectors in C++ all the time and never had this problem. Thanks for all your help in advance.
Dave Christman
private void jButton4MouseClicked(java.awt.event.MouseEvent evt) {
// Add your handling code here:
try{
iFile = new File(openFilePath);
BufferedReader fIn = new BufferedReader(new FileReader(iFile));
oFile = new File(saveFilePath);
// BufferedWriter fOut = new BufferedWriter(new FileWriter(oFile));
Vector svector = new Vector();
Iterator isiterator = svector.iterator();
String line = fIn.readLine();
while(line!= null)
{
svector.add(line);
line = fIn.readLine();
}
int vecsize = svector.size();
System.out.println(vecsize);
fIn.close();
while(isiterator.hasNext())
System.out.print(isiterator.next());
}
catch (IOException e)
{
System.out.println(openFilePath + " cannot be opened."
}
}
Can anyone tell me what is wrong here. I used iterators and vectors in C++ all the time and never had this problem. Thanks for all your help in advance.
Dave Christman