0

I am reading a csv file through CSVReader of Apache in a java application. This csv contains some italian characters like 'è'. When I am running this application on my local tomcat server then it is reading such characters correctly. but when I am deploying same application on remote Tomcat server. Then it is reading these characters as '?'.

Note: in both the cases deployed application is same, CSV file is same, accessing the application from the same system. Only the difference is one is running on local machine and other is on remote machine.

I am reading this file through InputStreamreader. Any one has the idea what can be the issue?

Infotechie
  • 1,653
  • 6
  • 23
  • 35

2 Answers2

1

It seems likely that you missed to specify the character encoding in which the CSV file is encoded with.

http://docs.oracle.com/javase/6/docs/api/java/io/InputStreamReader.html

Probably specifying this into the constructor of the InputStreamReader may fix your issue.

If you don't specify one, it uses the default character encoding, which i fear may change depending on the java virtual machine, as specidfied here:

http://docs.oracle.com/javase/1.5.0/docs/api/java/nio/charset/Charset.html#defaultCharset()

funforums
  • 326
  • 1
  • 12
  • had the same problem some time ago, and fixed it by passing the Charset into InputStreamReader's constructor. – Raibaz May 30 '13 at 16:15
0

Compare the locale settings.

On the operating system level, for example on Linux, this is:

$ echo $LANG de_DE.UTF-8

In Java, check the file.encoding in the system properties:

file.encoding=[UTF-8]

If you do not want to rely on the settings in the operating system, pass the charset explicitly in your code.

Beryllium
  • 12,808
  • 10
  • 56
  • 86