开发者

Ignore abnormal characters when reading file in java

I'm using a servlet to parse a log file and sends the data as json to a jsp page. The log file contains characters that JSON.parse() won't handle. An example of strange characters is "»7í¿7í∏h". I also know that my json format is correct.

I've tried reading/writing the file using utf-8, utf-16, iso-885开发者_JAVA百科9-1 and a few more but to no avail. Now I'm looking at finding the strange characters (which are very probably not needed) and ignoring them while reading the file in java.

Is there some way (perhaps in the servlet) I can find characters that json.parse() won't be able to parse?


The solution was to change json parser from the standard json.parse() to json_parse.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜