반응형
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | public String fileType(String filePath) throws MagicParseException, MagicMatchNotFoundException, MagicException, IOException { System.out.println("filePath : >>>>> " + filePath ); System.out.println("filePath : >>>>> " + filePath ); System.out.println("filePath : >>>>> " + filePath ); String fType =""; String rstType =""; Magic parser = new Magic(); FileInputStream is = new FileInputStream(filePath); byte[] data=new byte[512]; is.read(data); try{ MagicMatch match = parser.getMagicMatch(data); System.out.println("Fil Type : "+match.getMimeType()); rstType = match.getMimeType().substring(match.getMimeType().indexOf("/")+1); System.out.println(rstType); }catch(Exception e){ e.printStackTrace(); //fType="non"; }finally{ is.close(); } if(rstType.equals("zip")){ fType="zip"; }else if(rstType.equals("x-gzip")){ fType="gz"; }else if(rstType.equals("x-tar")){ fType="tar"; }else { fType="non"; } System.out.println("##################### >> type >>>> " + fType); return fType; } | cs |
반응형
'IT 연구회' 카테고리의 다른 글
Fog Computing (0) | 2017.07.30 |
---|---|
Decision Tree (1) | 2017.07.05 |
SLA(Service Level Agreement) (0) | 2017.07.04 |
owasp 2013 (0) | 2017.01.03 |
AAA (0) | 2016.10.28 |
[네트워크] 네트워크 설정 파일 (0) | 2016.02.13 |
[정보보안] 스시템 위험성에 따른 log 단계 (0) | 2016.02.10 |
[정보보안] 포트별 취약성 권고안 (0) | 2016.02.10 |
이클립스 단축키 모음 (0) | 2015.12.29 |
아두이노 교육 : 멀티캠퍼스 (0) | 2015.12.12 |