JAVA 遍历UFT-8所有中文
作者:互联网
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class Chinese {
public static void main(String[] args) {
int start = Integer.parseInt("4e00",16);
int end = Integer.parseInt("9fa5",16);
StringBuilder stringBuilder = new StringBuilder();
for (int i = start; i < end; i++) {
stringBuilder.append((char) i);
stringBuilder.append('\n');
}
try {
// 文件保存到项目目录下
File file = new File("text.txt");
file.createNewFile();
FileWriter fileWriter = new FileWriter(file);
fileWriter.write(stringBuilder.toString());
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
标签:遍历,JAVA,io,java,int,stringBuilder,file,fileWriter,UFT 来源: https://www.cnblogs.com/Haidnor/p/12241083.html