'Why does file generated by Sping Boot application have different encoding when app runs locally (in IntelliJ) and once deployed on Ubuntu server?
How can I ensure that the deployed application running on Ubuntu generates a file that has the same encoding as my file created when my app runs locally in IntelliJ ?
I've set the pom.xml to have the below
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
but I'm still seeing the same issue. Any ideas on how to ensure the files generated locally and on deployed app are identical ?
Thanks in advance!
Solution 1:[1]
Line ending differences are completely unrelated to character set encoding.
You can either use System.lineSeparator(), which will write the appropriate line separator for the platform the process runs on, or pick one (LF or CRLF), always use that, and write your code based on that.
Note that readLine() works with either:
Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), a carriage return followed immediately by a line feed, or by reaching the end-of-file (EOF).
If you are writing the file using println() then you'll get the default line separator for the platform the code runs on. You'll get \n on Linux, and \r\n on Windows. If you need to force one line ending regardless of the platform, then you must use print() instead and write your own line endings.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
