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()); }
This web page and associated content is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.
https://256stuff.com/sources/simplemagic/
Free Spam Protection Eggnog Recipe Android ORM Simple Java Magic JMX using HTTP OAuth 2.0 Simple Example Great Eggnog Recipe Christopher Randolph
Your host: (none) 175.223.11.144:65252
Your browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
다운
링크 : https://github.com/j256/simplemagic
GitHub - j256/simplemagic: Simple file magic number and content-type library which provides mime-type determination from files a
Simple file magic number and content-type library which provides mime-type determination from files and byte arrays - GitHub - j256/simplemagic: Simple file magic number and content-type library wh...
github.com
'Study > Java' 카테고리의 다른 글
[Encode] java replaceall 특수문자 (0) | 2022.07.07 |
---|---|
[java] replaceAll 정리 (0) | 2022.07.07 |
[Java] UUID란? (0) | 2022.07.01 |
[Java] MultipartFile과 File의 차이점 (0) | 2022.07.01 |
[JAVA] 입출력 스트림 (InputStream, OutputStream)란? (0) | 2022.07.01 |
댓글