FileReader & PrintWriter
Posted on 2004-04-10
Can a FileReader object get written twice? I just create a file using PrintWriter with a FileReader object as its argument. Result of that is a file created. Then i need to write something to that file which just created. So i create a printWriter object again with that FileReader object. But that doesnt work. Can someone help?
public void writeFile(FileReader in) throws java.io.IOException
PrintWriter out = new PrintWriter(writer);
BufferedReader inFile = new BufferedReader(in);
String line =null;
int j = 1;
while ((line = inFile.readLine())!= null)
out.println(j+ " : " + line);
so I first call
then i do:
PrintWriter err = new PrintWriter(parser.writer);
// add any error messages to the listing file...
for (int i=0; i<parser.errors.size(); i++)
String k = (String)parser.errors.get(i);
the problem is nothing being added to the file which just created.