//encoding
compile 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3'
File file = new File(path);
FileInputStream is = new FileInputStream(file);
UniversalDetector detector = new UniversalDetector(null);
byte[] buffer = new byte[is.available()];
is.read(buffer);
is.close();
detector.handleData(buffer, 0, buffer.length);
detector.dataEnd();
String text = new String(buffer, detector.getDetectedCharset());
No comments:
Post a Comment