import info.monitorenter.cpdetector.io.CodepageDetectorProxy;
import info.monitorenter.cpdetector.io.JChardetFacade;
import java.io.File;
import java.nio.charset.Charset;
public class CharacterEnding {
public static String getFileCharacterEnding(String filePath) {
File file = new File(filePath);
return getFileCharacterEnding(file);
}
public static String getFileCharacterEnding(File file) {
String fileCharacterEnding = "1 =";
CodepageDetectorProxy detector = CodepageDetectorProxy.getInstance();
detector.add(JChardetFacade.getInstance());
Charset charset = null;
try {
charset = detector.detectCodepage(file.toURL());
} catch (Exception e) {
e.printStackTrace();
}
if (charset != null) {
fileCharacterEnding = charset.name();
}
return fileCharacterEnding;
}
}