problemas con I/O

rodrigo
28 de Septiembre del 2004
tengo lo siguiente
int theLength=aOldPatternString.length;
BufferedWriter theBufferedWriter = new BufferedWriter(new FileWriter(itsFileNameOuput));
for (int i = 0; i <theLength ; i++)
{
String theOldPtrStr=aOldPatternString[i].toString();
String theNewPtrStr=aNewPatternString[i].toString();
findPatternLines(theOldPtrStr,theNewPtrStr,itsBufferedReader,theBufferedWriter);
}
//aca cierro los stream abiertos que son theBufferedWriter); y itsBufferedReader
closeStream(itsBufferedReader, theBufferedWriter);
////.......
//itsBufferedReader es un campo de la clase tipo BufferedReader
Resulta que la primera iteracion la realiza bien..
al iterar por seguna o mas veces y rescatar una linea del Buffered, estas son todas null..

los otros metodos son :
private void findPatternLines(String aOldPatternString,String aNewPatternString,
/*LineNumberReader*/BufferedReader aInputLineNumberReader,BufferedWriter aOutputBufferdWriter) throws IOException
{
Pattern theRegExpPattern = Pattern.compile(aOldPatternString);
String theLine = null;

while ((theLine = aInputLineNumberReader.readLine()) != null)
{
Matcher theExpressionMatcher = theRegExpPattern.matcher(theLine);

boolean theMatchExistBoolean=theExpressionMatcher.find();
if(theMatchExistBoolean)
{
String theMatchedLine = theExpressionMatcher.replaceAll(aNewPatternString);
aOutputBufferdWriter=copyLinesToFile(theMatchedLine,aOutputBufferdWriter);
}
else
aOutputBufferdWriter=copyLinesToFile(theLine,aOutputBufferdWriter);

}
itsLineNumberReader.reset();
//closeStream(aInputLineNumberReader, aOutputBufferdWriter);
}

y :
private void closeStream(BufferedReader aLineNumberReader,
BufferedWriter aBufferedWriter) throws IOException
{
aLineNumberReader.close();
aBufferedWriter.close();
}


private BufferedWriter copyLinesToFile(String aLine,
BufferedWriter aBufferedWriter) throws IOException
{
aBufferedWriter.write(aLine);
aBufferedWriter.newLine();
return aBufferedWriter;
}

¿Que estoy haciendo mal?
Gracias.