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
| 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 + ":");
String ligneLue;
while ((ligneLue = entree.readLine()) != null) {
StringTokenizer tok = new StringTokenizer(ligneLue, " ");
if(tok.countTokens() == 3)
{
x = Double.parseDouble(tok.nextToken().replace("(", ""));
y = Double.parseDouble(tok.nextToken());
z = Double.parseDouble(tok.nextToken().replace(")", ""));
System.out.println(x + " " + y + " " + z);
}
}
entree.close();
System.out.println("fin liste fichier" + nomfich);
}
} |
Partager