Skip to main content

Posts

Showing posts with the label DM_DEFAULT_ENCODING

Solved : DM_DEFAULT_ENCODING: Reliance on default encoding

DM_DEFAULT_ENCODING: Reliance on default encoding Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly. Lest assume you are reading a csv file using opencsv : CSVReader reader = new CSVReader(new FileReader(csvFilePath), ',', '"', 0) you will get this error as the file encoding is not mentioned and this can lead to data error while reading foreign text i.e unicode characters . To solve this challenge use input stream reader and provide encoding as below : CSVReader reader = new CSVReader(new InputStreamReader(new FileInputStream(csvFilePath), "UTF-8" ), ',', '"', 0) . Hope this helps