Leer ficheros con ReadLine()
Hola!
Necesitamos leer un fichero .txt y sacar los datos. Nos han dicho que lo hagamos con readLine() teniendo definido primero un File, luego un FileInputStream y luego un DataInputStream. pero no sabemos como hacerlo. Alguien podria ayudarnos con el código? Muchas gracias.
Necesitamos leer un fichero .txt y sacar los datos. Nos han dicho que lo hagamos con readLine() teniendo definido primero un File, luego un FileInputStream y luego un DataInputStream. pero no sabemos como hacerlo. Alguien podria ayudarnos con el código? Muchas gracias.
aqui hay un ejemplo
DataInputStream dis = null;
String aux = null;
try
{ dis = new DataInputStream(new BufferedInputStream(new FileInputStream("MiArchivo.txt")));
while((aux = dis.readLine()) != null)
System.out.println(aux);
}
catch(FileNotFoundException e){}
catch(IOException e){}
finally
{ try
{ dis.close();
}
catch(IOException e){}
}
DataInputStream dis = null;
String aux = null;
try
{ dis = new DataInputStream(new BufferedInputStream(new FileInputStream("MiArchivo.txt")));
while((aux = dis.readLine()) != null)
System.out.println(aux);
}
catch(FileNotFoundException e){}
catch(IOException e){}
finally
{ try
{ dis.close();
}
catch(IOException e){}
}
