//
// 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;
}

Utf8BomRemover的更多相关文章

  1. java 清除 bom

    参考工具  http://akini.mbnet.fi/java/unicodereader/ Utf8BomRemover 清除bom的方法 package cn.com.do1.component ...

随机推荐

  1. 洛谷 P5542 [USACO19FEB]Painting The Barn

    题目传送门 解题思路: 二维差分的板子题.题解传送门 AC代码: #include<iostream> #include<cstdio> using namespace std ...

  2. cd oldpwd

    常用方式 环境变量OLDPWD表示前一次的当前目录.刚登录系统之后,这个变量是没有设置的. 环境变量PWD表示当前目录. 环境变量CDPATH用来指定cd命令的搜索路径,类似于PATH,它也是用:分隔 ...

  3. Maven工程配置依赖

    1.下载 安装 官网下载maven :http://maven.apache.org/download.cgi ,下载时候注意版本,IDEA旧版本如我用的2017在安装Maven时可能会报错,此时别下 ...

  4. web嵌入到原生的app里需要注意的事项

    1.https://www.cnblogs.com/shimily/articles/7943370.html 2.https://www.cnblogs.com/stoneniqiu/p/60771 ...

  5. 简单makefile示例

    Makefile cmd: - g++ 相信在linux下编程的没有不知道makefile的,刚开始学习linux平台下的东西,了解了下makefile的制作,觉得有点东西可以记录下. 下面是一个极其 ...

  6. Mybatis实现增删改查(二)

    1. 准备 请先完成Mybatis基本配置(一)的基本内容 2. 查询多条商品信息 1)在com.mybatis.dao.PartDao中增加接口函数 public List<PartInfo& ...

  7. Emoji表情符号兼容方案

    Emoji表情符号兼容方案 一 什么是Emoji    emoji就是表情符号:词义来自日语(えもじ,e-moji,moji在日语中的含义是字符) 表情符号现已普遍应用于手机短信和网络聊天软件. em ...

  8. python学习笔记-模块和包

    模块导入方法 1.import 语句 import module1[,module2[,...moduleN]] 当我们使用import语句的时候,Python解释器是怎么找到对应对文件对呢?答案是解 ...

  9. ftp主动和被动模式区别

    转载自:http://www.west999.com/cms/wiki/server/2018-11-16/49417.html FTP是基于TCP的服务的,FTP不同之处在于FTP使用两个端口,一个 ...

  10. TypeError: TF_SessionRun_wrapper: expected all values in input dict to be ndarray.

    在用Embedding时出现了这个问题,具体的代码: model.add(Embedding(input_dim = vocab_size, output_dim = embedding_vector ...