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라이브러리' 카테고리의 다른 글
Java split 쓰기 문자열 자르기 . 기준 자르기 (0) | 2018.09.28 |
---|---|
Table 구조 배열 가로 형식 출력(피벗) 알고리즘 (0) | 2018.09.20 |
JAVA 배열 내에 중복값 제거하기/출력하기 (0) | 2018.09.18 |
Array.asList 중복 제거 (0) | 2018.09.18 |
JAVA 형변환 종류들입니다 (0) | 2018.09.14 |