SimpleMagic example 입니다
SimpleMagic - Simple Magic Content and Mime Type Detection Java Package
Here's a quick "magic" number package that I whipped up which allows content-type (mime-type) determination from files and byte arrays. It makes use of the magic(5) Unix content-type files to implement the same functionality as the Unix file(1) command in Java which detects the contents of a file. It uses either internal config files or can read /etc/magic, /usr/share/file/magic, or other magic(5) files and determine file content from File, InputStream, or byte[].
- Download files: local repository central maven repository github
- Documentation:
- Support:
- Source control (Github): browse code
Simple Code Sample
The following is a quick code sample to help you get started using the library for mime-type detection.
// create a magic utility using the internal magic file ContentInfoUtil util = new ContentInfoUtil(); // if you want to use a different config file(s), you can load them by hand: // ContentInfoUtil util = new ContentInfoUtil("/etc/magic"); ... ContentInfo info = util.findMatch("/tmp/upload.tmp"); // or ContentInfo info = util.findMatch(inputStream); // or ContentInfo info = util.findMatch(contentByteArray); // display content type information if (info == null) { System.out.println("Unknown content-type"); } else { // other information in ContentInfo type System.out.println("Content-type is: " + info.getName()); }
Free Spam Protection Eggnog Recipe Android ORM Simple Java Magic JMX using HTTP OAuth 2.0 Simple Example Great Eggnog Recipe Christopher Randolph
다운
링크 : https://github.com/j256/simplemagic
'Java' 카테고리의 다른 글
※ JAVA 배열 내에 중복값 제거하기/출력하기 (0) | 2018.09.18 |
---|---|
Arrays.asList 중복제거,java 배열중복제거 (0) | 2018.09.18 |
ORM, JPA Hibernate 란? (0) | 2018.03.16 |
프로그래머 모의테스트해설 문제1 (0) | 2018.03.13 |
java 한글 깨짐 찾기 (0) | 2018.01.25 |