zoukankan      html  css  js  c++  java
  • Utf8BomRemover

    //
    // Source code recreated from a .class file by IntelliJ IDEA
    // (powered by Fernflower decompiler)
    //
    
    package com.company;
    
    import java.io.File;
    import java.io.IOException;
    import java.util.Collection;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import org.apache.commons.io.DirectoryWalker;
    import org.apache.commons.io.FileUtils;
    
    public class Utf8BomRemover extends DirectoryWalker {
      private String extension = null;
      private JFrame jFrame;
      private int count;
    
      public Utf8BomRemover(JFrame controller, String extension) {
        this.extension = extension;
        this.jFrame = this.jFrame;
        this.count = 0;
      }
    
      public void start(File rootDir) throws IOException {
        this.walk(rootDir, (Collection)null);
      }
    
      protected void handleFile(File file, int depth, Collection results) throws IOException {
        this.remove(file);
        ++this.count;
      }
    
      protected void handleEnd(Collection results) throws IOException {
        JOptionPane.showMessageDialog(this.jFrame, "你成功修改" + this.count + "个.java编码的BOM文件");
      }
    
      private void remove(File file) throws IOException {
        byte[] bs = FileUtils.readFileToByteArray(file);
        if (bs[0] == -17 && bs[1] == -69 && bs[2] == -65) {
          byte[] nbs = new byte[bs.length - 3];
          System.arraycopy(bs, 3, nbs, 0, nbs.length);
          FileUtils.writeByteArrayToFile(file, nbs);
        }
    
      }
    }
    if(contents.length > 2 && (contents[0]&0xFF) == 0xEF && (contents[1] & 0xFF) == 0xBB && (contents[2] & 0xFF) == 0xBF) {  
        byte[] trim = new byte[contents.length - 3];  
        System.arraycopy(contents, 3, trim, 0, trim.length);    
        return trim;  
    }
  • 相关阅读:
    YTU 2543: 数字整除
    YTU 2542: 弟弟的作业
    YTU 2541: 汽水瓶
    YTU 2535: C++复数运算符重载(+与<<)
    YTU 2530: 小勇玩lol
    YTU 2520: 小慧唱卡拉OK
    YTU 2517: 打倒魔王↖(^ω^)↗
    YTU 2516: 剪刀石头布
    reload、replace、href、assign、window.history.go(0)的区别
    js 数组排序sort方法
  • 原文地址:https://www.cnblogs.com/tonggc1668/p/11344837.html
Copyright © 2011-2022 走看看