After reading the csv file in Java, I was insanely troubled when processing strings.
--Background --Since there is a half-width space at the beginning of the character string, it could not be converted to int type. ――So, let's erase the half-width space! ――… Half-width space does not disappear! !! !!
As a simple method, perform String.trim (). (Unicode of the space at this time is ** \ u0020 **)
Even so, there is a space that does not disappear (unicode ** \ u00A0 **, etc.), but it was organized on the following site, so please refer to it. https://eng-entrance.com/java-string-trim
But this space didn't disappear by itself ...
When it is output to the error log, the same display as "" (normal space) appears. If you copy and paste the space output at this time, a character code different from the normal space will be displayed. The unicode at that time \uFEFF ……… Um, who?
When I looked it up, this was the BOM unicode http://e-words.jp/w/BOM.html.
If you know this, you can replace it! ** Supported by String.replace ("\ uFEFF", "") **
** Space (like) has disappeared! Solution **
It seems that an error occurred because the read csv used UTF-8
Recommended Posts