private String initBookEncode(FileInputStream fileInputStream) { String encode = "gb2312"; try{ byte[] head = new byte[3]; fileInputStream.read(head); if(head[0]==-17 && head[1]==-69 && head[2] ==-65) encode = "UTF-8"; else if (head[0] == -1 && head[1] == -2 ) encode = "UTF-16"; else if (head[0] == -2 && head[1] == -1 ) encode = "Unicode"; }catch (IOException e) { Log.e(Global.TAG, "can't get book encoding:"+e.getMessage()); } return encode; }