直接上代碼,實(shí)現(xiàn)方法很簡(jiǎn)單:
代碼實(shí)現(xiàn):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
public static boolean isBinary(File file) { boolean isBinary = false ; try { FileInputStream fin = new FileInputStream(file); long len = file.length(); for ( int j = 0 ; j < ( int ) len; j++) { int t = fin.read(); if (t < 32 && t != 9 && t != 10 && t != 13 ) { isBinary = true ; break ; } } } catch (Exception e) { e.printStackTrace(); } return isBinary; } |
如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
原文鏈接:http://blog.csdn.net/fzhlee/article/details/5724524