Java Is UTF8 isUTF8Encoding(String path)

Here you can find the source of isUTF8Encoding(String path)

Description

is UTF Encoding

License

Apache License

Declaration

public static boolean isUTF8Encoding(String path) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static boolean isUTF8Encoding(String path) throws IOException {
        InputStream in = new java.io.FileInputStream(path);
        byte[] b = new byte[3];
        in.read(b);/* w w w.jav  a2 s  .  c  o m*/
        in.close();
        if (b[0] == -17 && b[1] == -69 && b[2] == -65)
            return true;
        else
            return false;
    }
}

Related

  1. isUTF8(File f)
  2. isUTF8StringLengthValid(int min, int max, String string)