zoukankan      html  css  js  c++  java
  • eclipse GBK格式的项目转化为UTF-8(代码修改法)

    public static void main(String[] args) {
            String srcDirPath = "C:\Users\src";   
            //转为UTF-8编码格式源码路径   
            String utf8DirPath = "D:\src";   
                      
            //获取所有java文件   
            Collection<File> javaGbkFileCol =  FileUtils.listFiles(new File(srcDirPath), new String[]{"java"}, true);   
                      
            for (File javaGbkFile : javaGbkFileCol) {   
                  //UTF8格式文件路径   
                  String utf8FilePath = utf8DirPath+javaGbkFile.getAbsolutePath().substring(srcDirPath.length());   
                   //使用GBK读取数据,然后用UTF-8写入数据   
                  try {
                    FileUtils.writeLines(new File(utf8FilePath), "UTF-8", FileUtils.readLines(javaGbkFile, "GBK"));
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }          
            }  
        }

    需要用到commons-io-2.6.jar

  • 相关阅读:
    Andoird注册功能
    android注册功能
    寒假周总结六
    android登录功能
    Android登录功能
    android登录功能
    每日日报2021.1.24
    每日博客2021.1.23
    每日日报2021.1.22
    每日日报2021.1.21
  • 原文地址:https://www.cnblogs.com/yangqimo/p/8310590.html
Copyright © 2011-2022 走看看