src/ToCSV.java in poi2csv-0.0.1 vs src/ToCSV.java in poi2csv-0.0.2

- old
+ new

@@ -24,15 +24,16 @@ import org.apache.poi.ss.usermodel.FormulaEvaluator; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import java.io.File; import java.io.FileInputStream; -import java.io.FileWriter; import java.io.BufferedWriter; import java.io.FilenameFilter; +import java.io.FileOutputStream; import java.io.IOException; import java.io.FileNotFoundException; +import java.io.OutputStreamWriter; import java.util.ArrayList; /** * Demonstrates <em>one</em> way to convert an Excel spreadsheet into a CSV * file. This class makes the following assumptions; @@ -443,20 +444,20 @@ * @throws java.io.IOException Thrown to indicate and error occurred in the * underlying file system. */ private void saveCSVFile(File file) throws FileNotFoundException, IOException { - FileWriter fw = null; + OutputStreamWriter fw = null; BufferedWriter bw = null; ArrayList<String> line = null; StringBuffer buffer = null; String csvLineElement = null; try { System.out.println("Saving the CSV file [" + file.getName() + "]"); // Open a writer onto the CSV file. - fw = new FileWriter(file); + fw = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); bw = new BufferedWriter(fw); // Step through the elements of the ArrayList that was used to hold // all of the data recovered from the Excel workbooks' sheets, rows // and cells.