Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Report how long the CSV conversion took, helpful for a quick read per…

…formance test

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1572555 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 6d8a78a3738f263937f976117cf43338a855646a 1 parent 833ae00
Gagravarr authored February 27, 2014
31  src/examples/src/org/apache/poi/ss/examples/ToCSV.java
@@ -18,24 +18,24 @@ Licensed to the Apache Software Foundation (ASF) under one or more
18 18
 package org.apache.poi.ss.examples;
19 19
 
20 20
 
21  
-import org.apache.poi.ss.usermodel.WorkbookFactory;
22  
-import org.apache.poi.ss.usermodel.Workbook;
23  
-import org.apache.poi.ss.usermodel.Sheet;
24  
-import org.apache.poi.ss.usermodel.Row;
25  
-import org.apache.poi.ss.usermodel.Cell;
26  
-import org.apache.poi.ss.usermodel.DataFormatter;
27  
-import org.apache.poi.ss.usermodel.FormulaEvaluator;
28  
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
29  
-
  21
+import java.io.BufferedWriter;
30 22
 import java.io.File;
31 23
 import java.io.FileInputStream;
  24
+import java.io.FileNotFoundException;
32 25
 import java.io.FileWriter;
33  
-import java.io.BufferedWriter;
34 26
 import java.io.FilenameFilter;
35 27
 import java.io.IOException;
36  
-import java.io.FileNotFoundException;
37 28
 import java.util.ArrayList;
38 29
 
  30
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
  31
+import org.apache.poi.ss.usermodel.Cell;
  32
+import org.apache.poi.ss.usermodel.DataFormatter;
  33
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
  34
+import org.apache.poi.ss.usermodel.Row;
  35
+import org.apache.poi.ss.usermodel.Sheet;
  36
+import org.apache.poi.ss.usermodel.Workbook;
  37
+import org.apache.poi.ss.usermodel.WorkbookFactory;
  38
+
39 39
 /**
40 40
  * Demonstrates <em>one</em> way to convert an Excel spreadsheet into a CSV
41 41
  * file. This class makes the following assumptions;
@@ -669,6 +669,8 @@ public static void main(String[] args) {
669 669
         // for example - then the CSV file generated from one will overwrite
670 670
         // that generated from the other.
671 671
         ToCSV converter = null;
  672
+        boolean converted = true;
  673
+        long startTime = System.currentTimeMillis();
672 674
         try {
673 675
             converter = new ToCSV();
674 676
             if(args.length == 2) {
@@ -710,6 +712,7 @@ else if(args.length == 4) {
710 712
                     "\t\t\t\tthat obeys UNIX formatting conventions. If no\n" +
711 713
                     "\t\t\t\tvalue is passed, then the CSV file produced\n" +
712 714
                     "\t\t\t\twill obey Excel's formatting conventions.");
  715
+                converted = false;
713 716
             }
714 717
         }
715 718
         // It is not wise to have such a wide catch clause - Exception is very
@@ -723,6 +726,12 @@ else if(args.length == 4) {
723 726
             System.out.println("Message: " + ex.getMessage());
724 727
             System.out.println("Stacktrace follows:.....");
725 728
             ex.printStackTrace(System.out);
  729
+            converted = false;
  730
+        }
  731
+        
  732
+        if (converted) {
  733
+            System.out.println("Conversion took " + 
  734
+                  (int)((System.currentTimeMillis() - startTime)/1000) + " seconds");
726 735
         }
727 736
     }
728 737
 

0 notes on commit 6d8a78a

Please sign in to comment.
Something went wrong with that request. Please try again.