zoukankan      html  css  js  c++  java
  • JAVA本地TXT文件解决中文乱码问题

    import java.io.*;
    
    public class ReadFile {
    public static void main(String[] args) {
    
    try {
    File file = new File("E:\JavaLog/logs/1.txt");
    if (file.isFile() && file.exists()) {
    //读取的时指定GBK编码格式,若中文出现乱码请尝试utf-8,window默认编码格式为GBK
    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "gbk"));
    String lineTxt = null;
    while ((lineTxt = br.readLine()) != null) {
    System.out.println(lineTxt);
    }
    br.close();
    } else {
    System.out.println("文件不存在!");
    }
    } catch (Exception e) {
    System.out.println("文件读取错误!");
    }
    }
    }

    原文:https://www.cnblogs.com/hechenhao/p/7773721.html

  • 相关阅读:
    磁盘管理RAID
    06磁盘
    7.30
    作业
    chapter02作业
    2019-07-23
    Tomcat三种运行模式(BIO, NIO, APR)
    Tomcat监控管理
    tomcat中web站点的部署
    Tomcat访问控制
  • 原文地址:https://www.cnblogs.com/peachh/p/12079976.html
Copyright © 2011-2022 走看看