Java 中有 MIME 类型的枚举吗?
Possible Duplicate:
Interface/enum listing standard mime-type constants
Is there an enum (or something similar) which holds constants for the most common MIME types?
I'd like to deal with some constants rather than firing Strings here and there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,JDK 中没有一个。但是您可以从此类开始。
编辑:
现在我认为有一个更好的选择。使用 Guava 的 MediaType是一个被维护的类。
There is not one in the JDK that I am aware of. But there is this class that you can probably start with.
Edit:
Now there is a better option I think. Using Guava's MediaType is a class that is maintained.
不能有枚举,因为没有可能值的封闭集。
一些框架提供了包含字符串列表的便捷类。例如,JAX-RS (jsr311) 规范提供了一个类 javax.ws.rs.core.MediaType。
There cannot be an enum, since there is no closed set of possible values.
Several frameworks provide convenient classes that contain list of Strings. For example JAX-RS (jsr311) spec provides a class javax.ws.rs.core.MediaType.
Java 将一些 MIME 类型存储在 DataFlavor 中。
Java stores some MIME types in DataFlavor.