本文整理了Java中org.bitcoinj.core.Utils.toString()
方法的一些代码示例,展示了Utils.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.toString()
方法的具体详情如下:
包路径:org.bitcoinj.core.Utils
类名称:Utils
方法名:toString
[英]Constructs a new String by decoding the given bytes using the specified charset.
This is a convenience method which wraps the checked exception with a RuntimeException. The exception can never occur given the charsets US-ASCII, ISO-8859-1, UTF-8, UTF-16, UTF-16LE or UTF-16BE.
[中]通过使用指定的字符集对给定字节进行解码来构造新字符串。
这是一个方便的方法,它用RuntimeException包装已检查的异常。如果字符集为US-ASCII、ISO-8859-1、UTF-8、UTF-16、UTF-16LE或UTF-16BE,则永远不会发生异常。
代码示例来源:origin: greenaddress/GreenBits
private static List<String> decodeMnemonicCode(byte[] mnemonicCode) {
return decodeMnemonicCode(Utils.toString(mnemonicCode, "UTF-8"));
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
private static List<String> decodeMnemonicCode(byte[] mnemonicCode) {
return decodeMnemonicCode(Utils.toString(mnemonicCode, "UTF-8"));
}
代码示例来源:origin: fr.acinq/bitcoinj-core
private static List<String> decodeMnemonicCode(byte[] mnemonicCode) {
return decodeMnemonicCode(Utils.toString(mnemonicCode, "UTF-8"));
}
代码示例来源:origin: HashEngineering/dashj
private static List<String> decodeMnemonicCode(byte[] mnemonicCode) {
return decodeMnemonicCode(Utils.toString(mnemonicCode, "UTF-8"));
}
代码示例来源:origin: greenaddress/GreenBits
public BitcoinPacketHeader(ByteBuffer in) throws ProtocolException, BufferUnderflowException {
header = new byte[HEADER_LENGTH];
in.get(header, 0, header.length);
int cursor = 0;
// The command is a NULL terminated string, unless the command fills all twelve bytes
// in which case the termination is implicit.
for (; header[cursor] != 0 && cursor < COMMAND_LEN; cursor++) ;
byte[] commandBytes = new byte[cursor];
System.arraycopy(header, 0, commandBytes, 0, cursor);
command = Utils.toString(commandBytes, "US-ASCII");
cursor = COMMAND_LEN;
size = (int) readUint32(header, cursor);
cursor += 4;
if (size > Message.MAX_SIZE || size < 0)
throw new ProtocolException("Message size too large: " + size);
// Old clients don't send the checksum.
checksum = new byte[4];
// Note that the size read above includes the checksum bytes.
System.arraycopy(header, cursor, checksum, 0, 4);
cursor += 4;
}
}
代码示例来源:origin: greenaddress/GreenBits
protected String readStr() throws ProtocolException {
long length = readVarInt();
return length == 0 ? "" : Utils.toString(readBytes((int) length), "UTF-8"); // optimization for empty strings
}
代码示例来源:origin: HashEngineering/dashj
protected String readStr() throws ProtocolException {
long length = readVarInt();
return length == 0 ? "" : Utils.toString(readBytes((int) length), "UTF-8"); // optimization for empty strings
}
代码示例来源:origin: fr.acinq/bitcoinj-core
public BitcoinPacketHeader(ByteBuffer in) throws ProtocolException, BufferUnderflowException {
header = new byte[HEADER_LENGTH];
in.get(header, 0, header.length);
int cursor = 0;
// The command is a NULL terminated string, unless the command fills all twelve bytes
// in which case the termination is implicit.
for (; header[cursor] != 0 && cursor < COMMAND_LEN; cursor++) ;
byte[] commandBytes = new byte[cursor];
System.arraycopy(header, 0, commandBytes, 0, cursor);
command = Utils.toString(commandBytes, "US-ASCII");
cursor = COMMAND_LEN;
size = (int) readUint32(header, cursor);
cursor += 4;
if (size > Message.MAX_SIZE || size < 0)
throw new ProtocolException("Message size too large: " + size);
// Old clients don't send the checksum.
checksum = new byte[4];
// Note that the size read above includes the checksum bytes.
System.arraycopy(header, cursor, checksum, 0, 4);
cursor += 4;
}
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
protected String readStr() throws ProtocolException {
long length = readVarInt();
return length == 0 ? "" : Utils.toString(readBytes((int) length), "UTF-8"); // optimization for empty strings
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
public BitcoinPacketHeader(ByteBuffer in) throws ProtocolException, BufferUnderflowException {
header = new byte[HEADER_LENGTH];
in.get(header, 0, header.length);
int cursor = 0;
// The command is a NULL terminated string, unless the command fills all twelve bytes
// in which case the termination is implicit.
for (; header[cursor] != 0 && cursor < COMMAND_LEN; cursor++) ;
byte[] commandBytes = new byte[cursor];
System.arraycopy(header, 0, commandBytes, 0, cursor);
command = Utils.toString(commandBytes, "US-ASCII");
cursor = COMMAND_LEN;
size = (int) readUint32(header, cursor);
cursor += 4;
if (size > Message.MAX_SIZE || size < 0)
throw new ProtocolException("Message size too large: " + size);
// Old clients don't send the checksum.
checksum = new byte[4];
// Note that the size read above includes the checksum bytes.
System.arraycopy(header, cursor, checksum, 0, 4);
cursor += 4;
}
}
代码示例来源:origin: fr.acinq/bitcoinj-core
protected String readStr() throws ProtocolException {
long length = readVarInt();
return length == 0 ? "" : Utils.toString(readBytes((int) length), "UTF-8"); // optimization for empty strings
}
代码示例来源:origin: HashEngineering/dashj
public BitcoinPacketHeader(ByteBuffer in) throws ProtocolException, BufferUnderflowException {
header = new byte[HEADER_LENGTH];
in.get(header, 0, header.length);
int cursor = 0;
// The command is a NULL terminated string, unless the command fills all twelve bytes
// in which case the termination is implicit.
for (; header[cursor] != 0 && cursor < COMMAND_LEN; cursor++) ;
byte[] commandBytes = new byte[cursor];
System.arraycopy(header, 0, commandBytes, 0, cursor);
command = Utils.toString(commandBytes, "US-ASCII");
cursor = COMMAND_LEN;
size = (int) readUint32(header, cursor);
cursor += 4;
if (size > Message.MAX_SIZE || size < 0)
throw new ProtocolException("Message size too large: " + size);
// Old clients don't send the checksum.
checksum = new byte[4];
// Note that the size read above includes the checksum bytes.
System.arraycopy(header, cursor, checksum, 0, 4);
cursor += 4;
}
}
内容来源于网络,如有侵权,请联系作者删除!