java自动获取文件的编码
java自动获取文件的编码
调用方式:
String filePath="D:/test.txt";
String fileEncode=EncodingDetect.getJavaEncode(filePath);
String fileContent=FileUtils.readFileToString(new File(filePath),fileEncode);
下面是EncodingDetect的全部代码:
package common.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import .URL;
/**
*
* Copyright (C) <2009>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option)