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
| import java.io.*;
import java.util.*; // pour StringTokeniser
public class Main {
// Lecture dans un fichier texte
public static void main (String args[]) throws IOException
{
String nomfich;
double x,y,z;
nomfich="U.txt";
BufferedReader entree = new BufferedReader (new FileReader (nomfich));
System.out.println("Nombres contenus dans le fichier "+ nomfich +":");
while (true)
{String ligneLue = entree.readLine();
if (ligneLue==null) break;
StringTokenizer tok= new StringTokenizer (ligneLue," ");
x=Double.parseDouble(tok.nextToken());
y=Double.parseDouble(tok.nextToken());
z=Double.parseDouble(tok.nextToken());
System.out.println (x + " "+y+" "+z);
}
entree.close ();
System.out.println("fin liste fichier"+nomfich);
}
} |
Partager