GreatKhan
06-18-2007, 07:15 AM
Yeah, basically Im getting errors using Iterator itr and ArrayList words in main. Not sure how to fix it up, had this error way back when I was learning java.. shouldnt have taken a break from programing ><
import java.util.*;
import java.io.*;
import javax.swing.*;
public class wordFinder
{
public ArrayList words=new ArrayList();
public Iterator itr;
public static void main(String args[])
{
try
{
FileReader read=new FileReader("C:\x.txt");
BufferedReader readBuffer=new BufferedReader(read);
String word = null;
while (((word=readBuffer.readLine()))!=null)
{
if ((word.length()==5) && (word.endsWith("z")))
words.add(word);
}
readBuffer.close();
}
catch (IOException e) {System.out.println(e);}
try
{
FileWriter write=new FileWriter("C:\xmod.txt");
BufferedWriter writeBuffer=new BufferedWriter(write);
itr = words.iterator();
while ( itr.hasNext ( ) )
{
writeBuffer.write((String)(itr.next()));
writeBuffer.newLine();
}
writeBuffer.close();
}
catch (IOException e) {System.out.println(e);}
}
}
import java.util.*;
import java.io.*;
import javax.swing.*;
public class wordFinder
{
public ArrayList words=new ArrayList();
public Iterator itr;
public static void main(String args[])
{
try
{
FileReader read=new FileReader("C:\x.txt");
BufferedReader readBuffer=new BufferedReader(read);
String word = null;
while (((word=readBuffer.readLine()))!=null)
{
if ((word.length()==5) && (word.endsWith("z")))
words.add(word);
}
readBuffer.close();
}
catch (IOException e) {System.out.println(e);}
try
{
FileWriter write=new FileWriter("C:\xmod.txt");
BufferedWriter writeBuffer=new BufferedWriter(write);
itr = words.iterator();
while ( itr.hasNext ( ) )
{
writeBuffer.write((String)(itr.next()));
writeBuffer.newLine();
}
writeBuffer.close();
}
catch (IOException e) {System.out.println(e);}
}
}