Skip to content

Commit

Permalink
Add UTF BOM handling code reading of csv's
Browse files Browse the repository at this point in the history
  • Loading branch information
janblom committed May 1, 2024
1 parent f0a50ef commit 36a07e1
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
******************************************************************************/
package org.ohdsi.utilities.files;

import org.apache.commons.io.input.BOMInputStream;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -46,11 +48,11 @@ public ReadTextFile(InputStream inputStream) {
public ReadTextFile(String filename) {
this.filename = filename;
try {
FileInputStream inputStream = new FileInputStream(filename);
InputStream inputStream = BOMInputStream.builder().setInputStream(new FileInputStream(filename)).get();
bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
System.err.println("Computer does not support UTF-8 encoding");
e.printStackTrace();
}
Expand Down

0 comments on commit 36a07e1

Please sign in to comment.