//
// 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. C++ 管道

    // PipeServer.cpp : Defines the entry point for the console application. // #include "stdafx.h& ...

  2. windows driver 获取文件属性

    OBJECT_ATTRIBUTES oa; FILE_NETWORK_OPEN_INFORMATION fnoi; UNICODE_STRING strPath = RTL_CONSTANT_STRI ...

  3. windows driver 分配内存

    UNICODE_STRING str = {0}; wchar_t strInfo[] = {L"马上就是光棍节了"}; str.Buffer = (PWCHAR)ExAlloca ...

  4. bugku-Web这是一个神奇的登陆框(sqlmap+bp)

    根据url提示是让sql注入,但万能密码又无效,这里我们用sqlmap+bp来解题. 首先输入用户密码来登录用bp抓包: 如图将其保存到txt文件中,然后用SQLmap来注入 输入命令暴库:sqlma ...

  5. django数据库读写分离

    django数据库读写分离 1. 配置数据库 settings.py文件中 用SQLite: DATABASES = { 'default': { 'ENGINE': 'django.db.backe ...

  6. 读取word模板,填充数据后导出

    一.需求说明 定期生成word报告,报告中含有文本.表格.图表等元素,依次获取进行替换,保留原有样式,生成新的word文档 二.引入依赖 <dependency> <groupId& ...

  7. PL/SQL 连接oracle步骤

    下面就将PL/SQL的配置说明一下. 一.安装Oracle客户端,让后配置    安装目录下面的C:\ORACLE\instantclient_11_2\NETWORK\ADMIN 的 tnsname ...

  8. Nginx无法监听虚拟VIP的问题报:99: Cannot assign requested address

    99: Cannot assign requested address #本地网卡上没有10.0.0.3这个IPNginx就会报错: [root@lb01 conf]# /application/ng ...

  9. 【MySQL 组复制】1.组复制技术简介

    组复制有两种模式 单主模式(single-primary/single-master)下自动选举出一个主节点,从而只允许在同一时刻只有该主节点可以更新数据. 对于MySQL的高级使用人员,可以通过复制 ...

  10. 图数据库ubentu环境neo4j安装

    1.下载进入官网下载https://neo4j.com/download-center/#releases 2.设置依赖仓库 wget -O - https://debian.neo4j.org/ne ...