1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
import java.io.* ;
public class Accdir
{ public static void main (String args[]) throws IOException
{ String nomfich ;
int n, num ;
RandomAccessFile entree ;
System.out.print ("donnez le nom du fichier a consulter : ") ;
nomfich = Clavier.lireString() ;
entree = new RandomAccessFile (nomfich, "r") ;
do
{ System.out.print ("Numero de lentier recherche : ") ;
num = Clavier.lireInt() ;
if (num == 0) break ;
entree.seek (4*(num-1)) ;
n = entree.readInt() ;
System.out.println (" valeur = " + n) ;
}
while (num != 0) ;
entree.close () ;
System.out.println ("*** fin consultation fichier ***");
}
} |
Partager