magicword.php,君无畏/simplemagic

This package provides some simple Java classes to read the magic files from Unix to simulate the file(1) command.

For more information, visit the home page:

http://256.com/sources/simplemagic/

The git repository is:

https://github.com/j256/simplemagic

Maven packages are published via the central repo:

http://repo1.maven.org/maven2/com/j256/simplemagic/simplemagic/

Enjoy,

Gray Watson

----------------------------------------------------------------------

To get started you use the SimpleMagic package like the following:

// 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);

Once you have the ContentDetails it provides:

* Enumerated type if the type is common

* Approximate content-name

* Full message produced by the magic file

* Mime-type string if one configured by the config file

For example:

HTML, mime 'text/html', msg 'HTML document text'

Java, msg 'Java serialization data, version 5'

PDF, mime 'application/pdf', msg 'PDF document, version 1.4'

gzip, mime 'application/x-gzip', msg 'gzip compressed data, was "", from Unix...'

GIF, mime 'image/gif', msg 'GIF image data, version 89a, 16 x 16'

PNG, mime 'image/png', msg 'PNG image, 600 x 371, 8-bit/color RGB, non-interlaced'

ISO, mime 'audio/mp4', msg 'ISO Media, MPEG v4 system, iTunes AAC-LC'

Microsoft, mime 'application/msword', msg 'Microsoft Word Document'

RIFF, mime 'audio/x-wav', msg 'RIFF (little-endian) data, WAVE audio, Microsoft...'

JPEG, mime 'image/jpeg', msg 'JPEG image data, JFIF standard 1.01'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值