/** * 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); }
public Byte parseValue(final String string, final ClassLoader classLoader) throws IllegalArgumentException { return Byte.decode(string.trim()); } });
/** * 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(); }
public Byte convert(String s) { return Byte.decode(s); } };
/** * 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(); }
return (T) (isHexNumber(trimmed) ? Byte.decode(trimmed) : Byte.valueOf(trimmed));
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);
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);
return (T) (isHexNumber(trimmed) ? Byte.decode(trimmed) : Byte.valueOf(trimmed));
/** * 将两个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; } /**
/** * 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; }
return (T) (isHexNumber(trimmed) ? Byte.decode(trimmed) : Byte.valueOf(trimmed));
@Override public Byte restore(String text) { return Byte.decode(text); } };
/** * Parses a string value as a byte. * @param value to parse * @return byte value */ public static byte parseString(String value) { return Byte.decode(value); }
@Override protected Number parseString(String s, int radix) throws NumberFormatException { return (radix == -1) ? Byte.decode(s) : Byte.parseByte(s, radix); } }
@Override public Byte convert(String source) { if (source == null || source.isEmpty()) { return new Byte((byte) 0); } else { return Byte.decode(source); } } }
/** 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; }
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();