|
JavaTM 2 Platform Std. Ed. v1.3 |
||||||
| FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +-- java.Lector
La clase Lector al igual que la clase Escritor es un interfaz para leer ficheros de texto de una forma muy intiuitiva y en español.
| Inner Class Summary |
| Constructor Summary | |
Lector()
|
|
| Method Summary | |
void |
Lector(String f) throws
IOException |
void |
leerEspacio() throws IOException
|
int |
leerEntero() throws IOException
|
int |
leerCaracter() throws IOException
|
StringXXX |
leerCadena() throws IOException
|
double |
leerSalto() throws IOException
|
void |
leerReal() throws IOException
|
void |
cerrar() |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Lector(StringXXX f) throws IOException
Descripción
Crea e inicializa un Lector para que pueda ser usado
Parámetros
StringXXX f
Nombre absoluto del fichero. Hay que tener cuidado ya que el carácter
/ es un carácter especial en los strings de java y por lo tanto hay que
ponerlo doble.
Ejemplo
Lector archivoALeer;
archivoALeer = new Lector(“d:\\redes\\tmp.txt”);
| Method Detail |
public void cerrar()
Descripción
Cierra un Lector para que cierre correctamente el sistema de ficheros.
Siempre hay que cerrar cualquier lector para dejar de trabajar con él.
Ejemplo
Lector archivoALeer;
archivoALeer = new Lector(“d:\\redes\\tmp.txt”);
archivoALeer.cerrar();
public void leerEspacio() throws IOException
Descripción
Lee todos los espacios que hay en el fichero hasta llegar a algun carácter
distinto del espacio.
Ejemplo
Lector archivoALeer;
archivoALeer = new Lector(“d:\\redes\\tmp.txt”);
archivoALeer.leerEspacio();
public int leerEntero() throws IOException
Descripción
Lee un número entero del fichero.
Ejemplo
Lector archivo;
archivo = new Lector(“d:\\redes\\tmp.txt”);
char c = archivo.leerCaracter();
public int leerCaracter() throws IOException
Descripción :
Lee un carácter del fichero.
Ejemplo :
Lector archivo;
archivo = new Lector(“d:\\redes\\tmp.txt”);
char c = archivo.leerCaracter();
public String leerCadena() throws IOException
Descripción
Lee una cadena de caracteres encerrada entre comillas dobles “cadena”
del fichero.
Ejemplo
Lector archivo;
archivo = new Lector(“d:\\redes\\tmp.txt”);
char c = archivo. leerCadena();
public void leerSalto() throws IOException
Descripción
Lee todos los espacios en blanco hasta encontrar un salto de linea que tambien
lo lee y deja la posicion de lectura al principio de la nueva linea.
Ejemplo
Lector archivo;
archivo = new Lector(“d:\\redes\\tmp.txt”);
archivo.leerSalto();
public double leerReal() throws IOException
Descripción
Lee un real.
Ejemplo
Lector archivo;
archivo = new Lector(“d:\\redes\\tmp.txt”);
double real = archivo. leerReal();
|
JavaTM 2 Platform Std. Ed. v1.3 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.