
Sometimes when we read a file, we switch between utf-8, gbk, and gb2312 encoding methods, but the code is still garbled. At this time, we need to check the encoding method of the file: (Recommended: java video tutorial)
1. You can directly view the file encoding in Vim
:set fileencoding
2. View the file encoding in subline
The default setting of Sublime Text is not to enable display encoding. If you want to enable it, you can use the menu Perference → Settings – User. In the open configuration file, after the curly brackets, add the following content:
// Display file encoding in the status bar "show_encoding": true, // Display line endings in the status bar "show_line_endings": true,
and then use The encoding method of the file is used to read the file so that it will not be garbled.
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-16LE"));
For more java knowledge, please pay attention to the java basic tutorial column.
The above is the detailed content of How to avoid reading garbled files in java. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.





