yshyee

需要commons-io-2.0.1.jar

public class Test {
    public static void main(String args[]) throws IOException{
        //GBK编码格式源码路径 
        String srcDirPath = "E:\\UTF8\\shshtv3\\src"; 
        //转为UTF-8编码格式源码路径 
        String utf8DirPath = "E:\\UTF8\\shsht\\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写入数据 
              FileUtils.writeLines(new File(utf8FilePath), "UTF-8", FileUtils.readLines(javaGbkFile, "GBK"));        
              System.out.println(utf8FilePath);
        }
    }
}

 

分类:

技术点:

相关文章:

  • 2021-10-07
  • 2022-02-21
  • 2021-11-30
  • 2021-11-30
  • 2022-12-23
  • 2021-12-10
  • 2021-12-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2021-08-18
相关资源
相似解决方案