1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| import java.io.* ;
import java.util.* ;
public class Lectxt
{ public static void main (String args[]) throws IOException
{ String nomfich ;
int x = 0;
int [] sommets ;
System.out.print ("donnez le nom du fichier contenant les arcs du graphe : ") ;
nomfich = Clavier.lireString() ;
BufferedReader entree = new BufferedReader (new FileReader (nomfich)) ;
System.out.println ("Sommets du fichier " + nomfich + " :") ;
while (true)
{ String ligneLue = entree.readLine() ;
if (ligneLue == null) break ;
StringTokenizer tok = new StringTokenizer (ligneLue, " ") ; // espace separateur
int nv = tok.countTokens() ;
for (int i=0 ; i<nv-1 ; i++)
{
x = Integer.parseInt (tok.nextToken()) ;
System.out.print ( x +" ");
}
}
entree.close () ;
System.out.println ("*** fin liste fichier ***");
}
} |
Partager