|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectMyReader
public class MyReader
Classe che ingloba un file e fornisce alcune funzioni per leggere stringhe, parole chiave, interi e double da tale file. Ha anche una funzione per leggere una stringa contenente al suo interno anche spazi, compresa fra due delimitatori (chiamiamo "titolo" una tale stringa). La classe Java FileInputStream (che e' anche un InputStream) non fornisce funzioni a questo scopo (devo leggere byte per byte).
Field Summary | |
---|---|
protected java.io.InputStream |
fd
File di input da cui leggere |
static char |
FINE
Delimitatore finale per stringa titolo. |
static char |
INIZIO
Delimitatore iniziale per stringa titolo. |
Constructor Summary | |
---|---|
MyReader(java.io.InputStream ffdd)
Crea reader su file gia' aperto. |
|
MyReader(java.lang.String name)
Apre file con nome dato e crea reader su quel file. |
Method Summary | |
---|---|
boolean |
findKeyword(java.lang.String kw)
Legge nel file una stringa e controlla che sia la parola chiave indicata. |
boolean |
isKeyword(java.lang.String s,
java.lang.String kw)
Controlla uguaglianza tra una stringa e una parola chiave assegnata, ritorna true se uguale e false se diversa. |
double |
readDouble()
Legge un numero reale e lo ritorna, lascia il file posizionato sul primo carattere seguente. |
int |
readInteger()
Legge un intero e lo ritorna, lascia il file posizionato sul primo carattere seguente. |
java.lang.String |
readString()
Legge una stringa e la ritorna, lascia il file posizionato sul primo carattere seguente. |
java.lang.String |
readTitle()
Legge un titolo (cioe' una stringa contenente anche spazi compresa tra delimitatore uno iniziale e uno finale). |
protected int |
skipWhitespace()
Salta spazi e ritorna codice del primo carattere non spazio (-1 se fine file). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.io.InputStream fd
public static final char INIZIO
public static final char FINE
Constructor Detail |
---|
public MyReader(java.lang.String name) throws java.io.IOException
java.io.IOException
public MyReader(java.io.InputStream ffdd)
Method Detail |
---|
protected int skipWhitespace() throws java.io.IOException
java.io.IOException
public java.lang.String readString() throws java.io.IOException
java.io.IOException
public boolean isKeyword(java.lang.String s, java.lang.String kw)
public boolean findKeyword(java.lang.String kw)
public int readInteger() throws java.io.IOException, java.lang.NumberFormatException
java.io.IOException
java.lang.NumberFormatException
public double readDouble() throws java.io.IOException, java.lang.NumberFormatException
java.io.IOException
java.lang.NumberFormatException
public java.lang.String readTitle() throws java.io.IOException
java.io.IOException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |