本文整理了Java中java.lang.Byte.parseByte()
方法的一些代码示例,展示了Byte.parseByte()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Byte.parseByte()
方法的具体详情如下:
包路径:java.lang.Byte
类名称:Byte
方法名:parseByte
[英]Parses the specified string as a signed decimal byte value. The ASCII character \u002d ('-') is recognized as the minus sign.
[中]将指定字符串解析为带符号的十进制字节值。ASCII字符\u002d('-')被识别为减号。
代码示例来源:origin: ctripcorp/apollo
@Override
public Byte apply(String input) {
return Byte.parseByte(input);
}
};
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Constructs a new MutableByte parsing the given string.
*
* @param value the string to parse, not null
* @throws NumberFormatException if the string cannot be parsed into a byte
* @since 2.5
*/
public MutableByte(final String value) {
super();
this.value = Byte.parseByte(value);
}
代码示例来源:origin: commons-lang/commons-lang
/**
* Constructs a new MutableByte parsing the given string.
*
* @param value the string to parse, not null
* @throws NumberFormatException if the string cannot be parsed into a byte
* @since 2.5
*/
public MutableByte(String value) throws NumberFormatException {
super();
this.value = Byte.parseByte(value);
}
代码示例来源:origin: code4craft/webmagic
@Override
public Byte formatTrimmed(String raw) throws Exception {
return Byte.parseByte(raw, 10);
}
代码示例来源:origin: redisson/redisson
public MutableByte(String value) {
this.value = Byte.parseByte(value);
}
代码示例来源:origin: alibaba/druid
public static Byte castToByte(Object val) {
if (val == null) {
return null;
}
if (val instanceof Byte) {
return (Byte) val;
}
if (val instanceof String) {
return Byte.parseByte((String) val);
}
return ((Number) val).byteValue();
}
代码示例来源:origin: libgdx/libgdx
/** Returns this value as a byte.
* @throws IllegalStateException if this an array or object. */
public byte asByte () {
switch (type) {
case stringValue:
return Byte.parseByte(stringValue);
case doubleValue:
return (byte)doubleValue;
case longValue:
return (byte)longValue;
case booleanValue:
return longValue != 0 ? (byte)1 : 0;
}
throw new IllegalStateException("Value cannot be converted to byte: " + type);
}
代码示例来源:origin: libgdx/libgdx
/** Returns this value as a byte.
* @throws IllegalStateException if this an array or object. */
public byte asByte () {
switch (type) {
case stringValue:
return Byte.parseByte(stringValue);
case doubleValue:
return (byte)doubleValue;
case longValue:
return (byte)longValue;
case booleanValue:
return longValue != 0 ? (byte)1 : 0;
}
throw new IllegalStateException("Value cannot be converted to byte: " + type);
}
代码示例来源:origin: stackoverflow.com
String[] arr = {"-1", "0", "10", "20" };
for (int i = 0; i < arr.length; i++) {
arr[i] = String.format("%02x", Byte.parseByte(arr[i]));
}
System.out.println(java.util.Arrays.toString(arr));
// prints "[ff, 00, 0a, 14]"
代码示例来源:origin: stackoverflow.com
String response = "[-47, 1, 16, 84, 2, 101, 110, 83, 111, 109, 101, 32, 78, 70, 67, 32, 68, 97, 116, 97]"; // response from the Python script
String[] byteValues = response.substring(1, response.length() - 1).split(",");
byte[] bytes = new byte[byteValues.length];
for (int i=0, len=bytes.length; i<len; i++) {
bytes[i] = Byte.parseByte(byteValues[i].trim());
}
String str = new String(bytes);
代码示例来源:origin: netty/netty
@Override
public byte convertToByte(CharSequence value) {
if (value instanceof AsciiString && value.length() == 1) {
return ((AsciiString) value).byteAt(0);
}
return Byte.parseByte(value.toString());
}
代码示例来源:origin: prestodb/presto
@Override
public byte getByte(String name)
{
return Byte.parseByte(getFieldValue(name));
}
代码示例来源:origin: prestodb/presto
public static long tinyintPartitionKey(String value, String name)
{
try {
return parseByte(value);
}
catch (NumberFormatException e) {
throw new PrestoException(HIVE_INVALID_PARTITION_VALUE, format("Invalid partition value '%s' for TINYINT partition key: %s", value, name));
}
}
代码示例来源:origin: redisson/redisson
@Override
public byte convertToByte(CharSequence value) {
if (value instanceof AsciiString && value.length() == 1) {
return ((AsciiString) value).byteAt(0);
}
return Byte.parseByte(value.toString());
}
代码示例来源:origin: apache/incubator-dubbo
public byte getParameter(String key, byte defaultValue) {
Number n = getNumbers().get(key);
if (n != null) {
return n.byteValue();
}
String value = getParameter(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
byte b = Byte.parseByte(value);
getNumbers().put(key, b);
return b;
}
代码示例来源:origin: apache/incubator-dubbo
public byte getParameter(String key, byte defaultValue) {
Number n = getNumbers().get(key);
if (n != null) {
return n.byteValue();
}
String value = getParameter(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
byte b = Byte.parseByte(value);
getNumbers().put(key, b);
return b;
}
代码示例来源:origin: apache/incubator-dubbo
public byte getMethodParameter(String method, String key, byte defaultValue) {
String methodKey = method + "." + key;
Number n = getNumbers().get(methodKey);
if (n != null) {
return n.byteValue();
}
String value = getMethodParameter(method, key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
byte b = Byte.parseByte(value);
getNumbers().put(methodKey, b);
return b;
}
代码示例来源:origin: apache/incubator-dubbo
public byte getMethodParameter(String method, String key, byte defaultValue) {
String methodKey = method + "." + key;
Number n = getNumbers().get(methodKey);
if (n != null) {
return n.byteValue();
}
String value = getMethodParameter(method, key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
byte b = Byte.parseByte(value);
getNumbers().put(methodKey, b);
return b;
}
代码示例来源:origin: apache/zookeeper
public byte readByte(String tag) throws IOException {
Value v = next();
if (!"ex:i1".equals(v.getType())) {
throw new IOException("Error deserializing "+tag+".");
}
return Byte.parseByte(v.getValue());
}
代码示例来源:origin: prestodb/presto
@LiteralParameters("x")
@ScalarOperator(CAST)
@SqlType(StandardTypes.TINYINT)
public static long castToTinyint(@SqlType("varchar(x)") Slice slice)
{
try {
return Byte.parseByte(slice.toStringUtf8());
}
catch (Exception e) {
throw new PrestoException(INVALID_CAST_ARGUMENT, format("Cannot cast '%s' to TINYINT", slice.toStringUtf8()));
}
}
内容来源于网络,如有侵权,请联系作者删除!