Descriptores BufferedReader

thejavamann
16 de Diciembre del 2007
Hola a todos:
Estoy haciendo una clase que esta formada por un descriptor BufferedReader. En dos de sus métodos recorro el fichero leyéndolo linea a linea. Entonces una vez leido y recorrido el fichero, el descriptor está al final de éste por lo que no soy capaz de hacer que ese descriptor vuelva al principio.
Si creo otro descriptor, me pasa lo mismo y no se como solucionarlo. La clase es la siguiente:
class TextSerializerReader
{
private static final String CONVERTER_FILE_NAME = "converterFile.txt"; //q coño es esto
//para que sirve el array converters
private ArrayList converters = new ArrayList();
private HashMap wrappers = new HashMap();
private BufferedReader br;

public TextSerializerReader(Reader reader ) throws FileNotFoundException,

CloneNotSupportedException, InstantiationException,
IllegalAccessException, ClassNotFoundException, IOException
{
br = new BufferedReader(reader);

/* FileReader fr = new FileReader(CONVERTER_FILE_NAME);
BufferedReader br = new BufferedReader(fr);
*/
String linea = br.readLine();

while ( linea != null )
{
StringTokenizer str= new StringTokenizer(linea,"|") ;
Object converter = Class.forName(str.nextToken()).newInstance();
converters.add( converter );
linea = br.readLine();
}
wrappers.put(Boolean.TYPE, Boolean.class);
wrappers.put(Character.TYPE, Character.class);
wrappers.put(Byte.TYPE, Byte.class);
wrappers.put(Short.TYPE, Short.class);
wrappers.put(Integer.TYPE, Integer.class);
wrappers.put(Long.TYPE, Long.class);
wrappers.put(Long.TYPE, Long.class);
wrappers.put(Double.TYPE, Double.class);
}

public Object read() throws TypeErrorException, IOException
{
Object object;

try
{
String linea = br.readLine();
if (linea != null)
{
StringTokenizer st1 = new StringTokenizer(linea, "|");
String className = st1.nextToken();
String attributtes = st1.nextToken();
Class objectClass = Class.forName(className);
object = objectClass.newInstance();
StringTokenizer st2 = new StringTokenizer(attributtes, "&");
while ( st2.hasMoreTokens() )
{
try
{
String attribute = st2.nextToken();
StringTokenizer st3 = new StringTokenizer(attribute, "=");
String attributeName = st3.nextToken();
String attributeValue = st3.nextToken();
Method setMethod = Support.getSetMethod(objectClass , attributeName);
Object attributeObject = createInstanceOf(setMethod.getParameterTypes()[0], attributeValue);
setMethod.invoke(object, new Object[] {attributeObject});
} catch (NoSuchFieldException e) { e.printStackTrace();}
catch (InvocationTargetException e) { e.printStackTrace(); }
catch (NoSuchMethodException e) { e.printStackTrace(); }
catch (IllegalAccessException e) { e.printStackTrace(); }
}
return object;
}
}
catch (InstantiationException e) { throw new TypeErrorException(e); }
catch (IllegalAccessException e) { throw new TypeErrorException(e); }
catch (ClassNotFoundException e) { throw new TypeErrorException(e); }
return null;
}
}

A ver si me podeis ayudar para que siga avanzando con esto. Muchas gracias por vuestro tiempo, espero vuestra respuesta.