Home > Java > javaTutorial > How to solve garbled characters when writing files in java

How to solve garbled characters when writing files in java

爱喝马黛茶的安东尼
Release: 2019-12-27 11:33:05
Original
3355 people have browsed it

How to solve garbled characters when writing files in java

When writing files with Chinese characters, it is easy to have garbled characters. Usually the files obtained are usually in "iso8859-1" format and need to be converted to "UTF-8" format. .

For example: String str = new String (str.getByte("iso8859-1"), "UTF-8"); just perform forced conversion and then store it.

Note: Usually the formats are GBK, UTf-8, iso8859-1, and GB2312. If the above forced conversion is unsuccessful, try these formats in sequence and the problem will definitely be solved.

PHP Chinese website has a large number of free JAVA introductory tutorials, everyone is welcome to learn!

The above is the detailed content of How to solve garbled characters when writing files in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template