Salut !
J'ai un pti problème, j'ai beau fouiller, je ne trouve pas...
Voila, j'utilise JFlex (là n'est pas le problème...) pour analyser un fichier.
Au début de mon scan j'affiche le temps dans la console.
Puis je redirige la sortie standard dans un fichier.
Enfin je ferme ce flux.
J'aimerai réafficher le temps dans la console à nouveau (à la fin du scan) mais ca ne fonctionne pas... Ca ne l'écrit même pas dans le fichier de log...
Voici mon code (au cas où)
Merci d'avance !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
43
44
45
46 /* decParser.flex */ import java.io.*; ... %{ // time start private long timeStart = System.currentTimeMillis(); // file output stream FileOutputStream fos; /** * redirect sdout to log file. */ public void openStream(){ try { fos = new FileOutputStream("./parsing.log",true); System.setOut(new PrintStream(fos,true)); } catch (Exception e) { e.printStackTrace(); } } /** * closes the stream. */ public void closeStream(){ try { fos.close(); } catch (Exception e) { e.printStackTrace(); } } %} /* Called at start of parsing */ %init{ long timeStart = System.currentTimeMillis(); System.out.println("start..."+timeStart); openStream(); %init} /* Called at end of file. */ %{eof closeStream(); long timeEnd = System.currentTimeMillis(); // C'EST ICI LE PROBLEME System.out.println ("\nEnd of file...\n"+nbTimeStamp +" timestamps found in "+((double)((timeEnd-timeStart)/1000))+" s. "+nbLines+" lines read"); %eof} ...
+++
Ju
Partager