convert from svn repository: remove tags directory
[lttv.git] / trunk / masters-pmf / java_speed_test / java / read_trace.java
index 80a3bc17cefc83438c1390cacd4ed8ad96a7896a..aacb08eb164835161b21c9ea6dbbbdd377b35b02 100644 (file)
@@ -3,10 +3,27 @@ import java.io.*;
 public class read_trace {
        public static void main(String[] args) {
                int tmp = 0;
+               boolean print = false;
+               String filename = "";
+
+               for(String s : args) {
+                       if(s.equals("-p")) {
+                               print = true;
+                       }
+                       else {
+                               filename = s;
+                       }
+               }
+               
+               if(filename.equals("")) {
+                       System.out.println("error: no filename specified");
+                       return;
+               }
 
                try {
-                       FileInputStream file_input = new FileInputStream ("../trace.dat");
-                       DataInputStream data_input = new DataInputStream (file_input);
+                       FileInputStream file_input = new FileInputStream (filename);
+                       BufferedInputStream buffered_input = new BufferedInputStream(file_input);
+                       DataInputStream data_input = new DataInputStream (buffered_input);
                        
                        int timestamp;
                        short id;
@@ -36,9 +53,8 @@ public class read_trace {
                                byte[] arg2 = new byte[strlen];
                                eargs_data.readFully(arg2, 0, strlen);
 
-                               //System.out.printf("timestamp %d id %d args=(short=%d string=\"%s\") %n", timestamp, id, arg1, new String(arg2));
-                               String strout = String.format("timestamp %d id %d args=(short=%d string=\"%s\") %n", timestamp, id, arg1, new String(arg2));
-                               tmp += strout.length();
+                               if(args.length>0 && args[0].equals("-p"))
+                                       System.out.printf("timestamp %d id %d args=(short=%d string=\"%s\") %n", timestamp, id, arg1, new String(arg2));
                        }
 
                }
@@ -48,6 +64,5 @@ public class read_trace {
                }
 
                //file_input.close();
-               System.out.println(tmp);
        }
 }
This page took 0.025595 seconds and 4 git commands to generate.