Java Utililty Methods Is UTF8

List of utility methods to do Is UTF8

  1. HOME
  2. Java
  3. I
  4. Is UTF8

Description

The list of methods to do Is UTF8 are organized into topic(s).

Method

boolean isUTF8(File f)
is UTF
boolean isUtf8 = false;
try {
 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]) {
...
boolean isUTF8Encoding(String path)
is UTF Encoding
InputStream in = new java.io.FileInputStream(path);
byte[] b = new byte[3];
in.read(b);
in.close();
if (b[0] == -17 && b[1] == -69 && b[2] == -65)
 return true;
else
 return false;
...
boolean isUTF8StringLengthValid(int min, int max, String string)
Check the validity of the Length of a UTF8 String.
if (string == null) {
 return false;
try {
 byte[] bytes = string.getBytes("UTF-8");
 return ((bytes.length >= min) && (bytes.length <= max));
} catch (UnsupportedEncodingException uee) {
return false;

AltStyle によって変換されたページ (->オリジナル) /