本文整理匯總了Java中org.apache.commons.codec.Charsets.US_ASCII屬性的典型用法代碼示例。如果您正苦於以下問題:Java Charsets.US_ASCII屬性的具體用法?Java Charsets.US_ASCII怎麽用?Java Charsets.US_ASCII使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.apache.commons.codec.Charsets
的用法示例。
在下文中一共展示了Charsets.US_ASCII屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: newStringUsAscii
public static String newStringUsAscii(byte[] bytes) {
return new String(bytes, Charsets.US_ASCII);
}
示例2: newStringUsAscii
/**
* Constructs a new <code>String</code> by decoding the specified array of bytes using the US-ASCII charset.
*
* @param bytes
* The bytes to be decoded into characters
* @return A new <code>String</code> decoded from the specified array of bytes using the US-ASCII charset,
* or {@code null} if the input byte array was {@code null}.
* @throws NullPointerException
* Thrown if {@link Charsets#US_ASCII} is not initialized, which should never happen since it is
* required by the Java platform specification.
* @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
*/
public static String newStringUsAscii(final byte[] bytes) {
return new String(bytes, Charsets.US_ASCII);
}
示例3: newStringUsAscii
/**
* Constructs a new <code>String</code> by decoding the specified array of bytes using the US-ASCII charset.
*
* @param bytes
* The bytes to be decoded into characters
* @return A new <code>String</code> decoded from the specified array of bytes using the US-ASCII charset,
* or <code>null</code> if the input byte array was <code>null</code>.
* @throws NullPointerException
* Thrown if {@link Charsets#US_ASCII} is not initialized, which should never happen since it is
* required by the Java platform specification.
* @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
*/
public static String newStringUsAscii(final byte[] bytes) {
return new String(bytes, Charsets.US_ASCII);
}