本文整理了Java中java.lang.Byte.decode()
方法的一些代码示例,展示了Byte.decode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Byte.decode()
方法的具体详情如下:
包路径:java.lang.Byte
类名称:Byte
方法名:decode
[英]Parses the specified string and returns a Byte instance if the string can be decoded into a single byte value. The string may be an optional minus sign "-" followed by a hexadecimal ("0x..." or "#..."), octal ("0..."), or decimal ("...") representation of a byte.
[中]解析指定的字符串并返回字节实例(如果该字符串可以解码为单个字节值)。字符串可以是可选的减号“-”,后跟十六进制(“0x…”或“#……”,八进制(“0…”),或十进制(“…”)字节的表示法。
代码示例来源:origin: vavr-io/vavr
/**
* Decodes this {@code CharSeq} into a {@code Byte} by calling {@link Byte#decode(String)}.
* <p>
* We write
*
* <pre><code>
* Byte value = charSeq.decodeByte();
* </code></pre>
*
* instead of
*
* <pre><code>
* Byte value = Byte.decode(charSeq.mkString());
* </code></pre>
*
* @return a {@code Byte} object holding the byte value represented by this {@code CharSeq}
* @throws NumberFormatException if this {@code CharSeq} does not contain a parsable byte.
*/
public Byte decodeByte() {
return Byte.decode(back);
}
代码示例来源:origin: wildfly/wildfly
public Byte parseValue(final String string, final ClassLoader classLoader) throws IllegalArgumentException {
return Byte.decode(string.trim());
}
});
代码示例来源:origin: com.h2database/h2
/**
* Returns the value as a byte.
*
* @param columnIndex (1,2,...)
* @return the value
*/
@Override
public byte getByte(int columnIndex) throws SQLException {
Object o = get(columnIndex);
if (o != null && !(o instanceof Number)) {
o = Byte.decode(o.toString());
}
return o == null ? 0 : ((Number) o).byteValue();
}
代码示例来源:origin: remkop/picocli
public Byte convert(String s) {
return Byte.decode(s);
}
};
代码示例来源:origin: lealone/Lealone
/**
* Returns the value as a byte.
*
* @param columnIndex (1,2,...)
* @return the value
*/
@Override
public byte getByte(int columnIndex) throws SQLException {
Object o = get(columnIndex);
if (o != null && !(o instanceof Number)) {
o = Byte.decode(o.toString());
}
return o == null ? 0 : ((Number) o).byteValue();
}
代码示例来源:origin: spring-projects/spring-framework
return (T) (isHexNumber(trimmed) ? Byte.decode(trimmed) : Byte.valueOf(trimmed));
代码示例来源:origin: alipay/sofa-rpc
resultList[i] = Boolean.parseBoolean(value);
} else if (byte.class.equals(cl) || Byte.class.equals(cl)) {
resultList[i] = Byte.decode(value);
} else if (short.class.equals(cl) || Short.class.equals(cl)) {
resultList[i] = Short.decode(value);
代码示例来源:origin: alipay/sofa-rpc
resultList[i] = Boolean.parseBoolean(value);
} else if (byte.class.equals(cl) || Byte.class.equals(cl)) {
resultList[i] = Byte.decode(value);
} else if (short.class.equals(cl) || Short.class.equals(cl)) {
resultList[i] = Short.decode(value);
代码示例来源:origin: org.springframework/spring-core
return (T) (isHexNumber(trimmed) ? Byte.decode(trimmed) : Byte.valueOf(trimmed));
代码示例来源:origin: jwpttcg66/NettyGameServer
/**
* 将两个ASCII字符合成一个字节;
* 如:"EF"--> 0xEF
* @param src0 byte
* @param src1 byte
* @return byte
*/
public static byte uniteBytes(byte src0, byte src1) {
byte _b0 = Byte.decode("0x" + new String(new byte[]{src0})).byteValue();
_b0 = (byte)(_b0 << 4);
byte _b1 = Byte.decode("0x" + new String(new byte[]{src1})).byteValue();
byte ret = (byte)(_b0 ^ _b1);
return ret;
}
/**
代码示例来源:origin: ebean-orm/ebean
/**
* Returns an alternative node id - set with the 'ebean.uuid.nodeId' system property.
*/
private static byte[] getAlternativeNodeId() {
try {
String altNodeId = System.getProperty("ebean.uuid.nodeId");
if (altNodeId != null) {
String[] components = altNodeId.split("-");
if (components.length != 5) {
throw new IllegalArgumentException("Invalid nodeId string: " + altNodeId);
}
byte[] nodeId = new byte[6];
for (int i=0; i<5; i++) {
nodeId[i] = Byte.decode("0x"+components[i]).byteValue();
}
return nodeId;
}
} catch (SecurityException se) {
// ignore
}
return null;
}
代码示例来源:origin: camunda/camunda-bpm-platform
return (T) (isHexNumber(trimmed) ? Byte.decode(trimmed) : Byte.valueOf(trimmed));
代码示例来源:origin: SquidPony/SquidLib
@Override
public Byte restore(String text) {
return Byte.decode(text);
}
};
代码示例来源:origin: com.espertech/com.springsource.com.espertech.esper
/**
* Parses a string value as a byte.
* @param value to parse
* @return byte value
*/
public static byte parseString(String value)
{
return Byte.decode(value);
}
代码示例来源:origin: org.jdesktop.bsaf/bsaf
@Override
protected Number parseString(String s, int radix) throws NumberFormatException {
return (radix == -1) ? Byte.decode(s) : Byte.parseByte(s, radix);
}
}
代码示例来源:origin: stackoverflow.com
byte[] temp = new byte[2];
temp[0] = Byte.decode("0xA");
temp[1] = Byte.decode("0xB");
System.out.println(temp[0]);
System.out.println(temp[1]);
代码示例来源:origin: net.oschina.jmind/jmind-base
private static byte uniteBytes(byte src0, byte src1) {
char _b0 = (char) Byte.decode("0x" + new String(new byte[] { src0 })).byteValue();
_b0 = (char) (_b0 << 4);
char _b1 = (char) Byte.decode("0x" + new String(new byte[] { src1 })).byteValue();
byte ret = (byte) (_b0 ^ _b1);
return ret;
}
代码示例来源:origin: baratine/baratine
@Override
public Byte convert(String source)
{
if (source == null || source.isEmpty()) {
return new Byte((byte) 0);
}
else {
return Byte.decode(source);
}
}
}
代码示例来源:origin: ldcsaa/JessMA
/** String -> Byte,如果转换不成功则返回 null */
public final static Byte str2Byte(String s)
{
Byte returnVal;
try {
returnVal = Byte.decode(safeTrimString(s));
} catch(Exception e) {
returnVal = null;
}
return returnVal;
}
代码示例来源:origin: stackoverflow.com
FileReader file = new FileReader("bytes.txt");
Scanner scanner = new Scanner(file);
scanner.useDelimiter(",");
ByteBuffer byteBuffer = new ByteBuffer(0);
while (scanner.hasNext()) {
byteBuffer.append(Byte.decode(scanner.next().trim()));
}
scanner.close();
内容来源于网络,如有侵权,请联系作者删除!