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 35 36 37 38 39 40 41 42
|
import java.io.*;
import java.util.*; // pour StringTokeniser
public class Main {
public static void main(String args[]) throws IOException {
//création du tableau
ArrayList v1x= new ArrayList ();
ArrayList v1y= new ArrayList ();
ArrayList v1z= new ArrayList ();
// Lecture du fichier vitesse à t=0.5s
String nomfich;
double x, y, z;
nomfich = "U_0,5.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(")", ""));
v1x.add(x);
v1y.add(y);
v1z.add(z);
//System.out.println(x + " " + y + " " + z);
}
}
entree.close();
System.out.println("vecteur vx1");
System.out.println(v1x);
System.out.println("vecteur vy1");
System.out.println(v1y);
System.out.println("vecteur vz1");
System.out.println(v1z);
System.out.println("fin liste fichier" + nomfich);
}
} |
Partager