Java是否有获取各种字节顺序标记的方法? [英] Does Java have methods to get the various byte order marks?

查看:237
本文介绍了Java是否有获取各种字节顺序标记的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Java中寻找一个实用程序方法或常量,它将返回与编码的相应字节顺序标记相对应的字节,但我似乎无法找到它。有吗?我真的想做类似的事情:

I am looking for a utility method or constant in Java that will return me the bytes that correspond to the appropriate byte order mark for an encoding, but I can't seem to find one. Is there one? I really would like to do something like:

byte[] bom = Charset.forName( CharEncoding.UTF8 ).getByteOrderMark();

其中 CharEncoding 来自Apache Commons。

Where CharEncoding comes from Apache Commons.

推荐答案

Apache Commons IO包含您要查找的内容,请参阅 org.apache.commons.io.ByteOrderMark

Apache Commons IO contains what you are looking for, see org.apache.commons.io.ByteOrderMark.

这篇关于Java是否有获取各种字节顺序标记的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆