gitweb on Svarog
projekti pod git sistemom za održavanje verzija -- projects under the git version control system
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 215cc95)
raw | patch | inline | side by side (parent: 215cc95)
| author | Doni Pracner <quinnuendo@gmail.com> | |
| Sun, 27 Jul 2014 22:39:43 +0000 (00:39 +0200) | ||
| committer | Doni Pracner <quinnuendo@gmail.com> | |
| Sun, 27 Jul 2014 22:39:43 +0000 (00:39 +0200) | 
| src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java | patch | blob | history | 
diff --git a/src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java b/src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java
index 4522d6502796e780d42eb09e6f7e1598c74c2840..3eac782d1c657fe7bbe0b6ca916f5ec4e4fff667 100644 (file)
     You should have received a copy of the GNU General Public License
     along with mjc2wsl.  If not, see <http://www.gnu.org/licenses/>.
 */
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Calendar;
+import java.util.Properties;
 import com.quemaster.transformations.TransMessages;
                                System.out.println("no filename supplied");
                                System.exit(2);
                        }
-                       File f = new File(args[i]);
+
+                       Path p = FileSystems.getDefault().getPath(args[i]);
+                       if (!Files.exists(p)){
+                               System.out.println("input file does not exist");
+                               System.exit(1);
+                       }
                        if (i + 1 < args.length) {
                                try {
                                        e.printStackTrace();
                                }
                        }
-                       if (f.exists()) {
-                               Calendar now = Calendar.getInstance();
-                               convertFile(f);
-                               long mili = Calendar.getInstance().getTimeInMillis()
-                                               - now.getTimeInMillis();
-                               System.out.println("conversion time:" + mili + " ms");
-                               messages.printMessageCounters();
-                               out.close();
-                       } else
-                               System.out.println("file does not exist");
+                       Calendar now = Calendar.getInstance();
+                       try {
+                               convertStream(Files.newInputStream(p));
+                       } catch (Exception e) {
+                               // TODO Auto-generated catch block
+                               e.printStackTrace();
+                       }
+                       long mili = Calendar.getInstance().getTimeInMillis()
+                                       - now.getTimeInMillis();
+                       System.out.println("conversion time:" + mili + " ms");
+                       messages.printMessageCounters();
+                       out.close();
                }
        }