Here you can find the source of isUTF8(File f)
public static boolean isUTF8(File f)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { private final static byte[] UTF_8_BOM = { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF }; public static boolean isUTF8(File f) { boolean isUtf8 = false; try {/*from ww w.j a va 2 s . co m*/ FileInputStream fis = new FileInputStream(f); byte[] bom = new byte[3]; fis.read(bom); fis.close(); if (null != bom && bom.length > 2 && bom[0] == UTF_8_BOM[0] && bom[1] == UTF_8_BOM[1] && bom[2] == UTF_8_BOM[2]) { isUtf8 = true; } } catch (Exception e) { return false; } return isUtf8; } }