本文整理匯總了Java中com.mysql.jdbc.StringUtils.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.toString方法的具體用法?Java StringUtils.toString怎麽用?Java StringUtils.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.mysql.jdbc.StringUtils
的用法示例。
在下文中一共展示了StringUtils.toString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readString
import com.mysql.jdbc.StringUtils; //導入方法依賴的package包/類
private String readString(final ByteBuffer byteBuffer) {
int i = byteBuffer.position();
int len = 0;
int maxLen = byteBuffer.limit();
while ((i < maxLen) && (byteBuffer.get(i) != 0)) {
len++;
i++;
}
String s = StringUtils.toString(byteBuffer.array(), byteBuffer.position(), len);
byteBuffer.position(byteBuffer.position() + len + 1);
return s;
}
示例2: unpack
import com.mysql.jdbc.StringUtils; //導入方法依賴的package包/類
/**
* Unpacks a binary representation of this event.
*
* @param buf
* the binary representation of this event
* @return the unpacked Event
* @throws Exception
* if an error occurs while unpacking the event
*/
public static ProfilerEvent unpack(byte[] buf) throws Exception {
int pos = 0;
byte eventType = buf[pos++];
long connectionId = readInt(buf, pos);
pos += 8;
int statementId = readInt(buf, pos);
pos += 4;
int resultSetId = readInt(buf, pos);
pos += 4;
long eventCreationTime = readLong(buf, pos);
pos += 8;
long eventDuration = readLong(buf, pos);
pos += 4;
byte[] eventDurationUnits = readBytes(buf, pos);
pos += 4;
if (eventDurationUnits != null) {
pos += eventDurationUnits.length;
}
readInt(buf, pos);
pos += 4;
byte[] eventCreationAsBytes = readBytes(buf, pos);
pos += 4;
if (eventCreationAsBytes != null) {
pos += eventCreationAsBytes.length;
}
byte[] message = readBytes(buf, pos);
pos += 4;
if (message != null) {
pos += message.length;
}
return new ProfilerEvent(eventType, "", "", connectionId, statementId, resultSetId, eventCreationTime, eventDuration,
StringUtils.toString(eventDurationUnits, "ISO8859_1"), StringUtils.toString(eventCreationAsBytes, "ISO8859_1"), null,
StringUtils.toString(message, "ISO8859_1"));
}
示例3: unpack
import com.mysql.jdbc.StringUtils; //導入方法依賴的package包/類
/**
* Unpacks a binary representation of this event.
*
* @param buf
* the binary representation of this event
* @return the unpacked Event
* @throws Exception
* if an error occurs while unpacking the event
*/
public static ProfilerEvent unpack(byte[] buf) throws Exception {
int pos = 0;
byte eventType = buf[pos++];
long connectionId = readInt(buf, pos);
pos += 8;
int statementId = readInt(buf, pos);
pos += 4;
int resultSetId = readInt(buf, pos);
pos += 4;
long eventCreationTime = readLong(buf, pos);
pos += 8;
long eventDuration = readLong(buf, pos);
pos += 4;
byte[] eventDurationUnits = readBytes(buf, pos);
pos += 4;
if (eventDurationUnits != null) {
pos += eventDurationUnits.length;
}
readInt(buf, pos);
pos += 4;
byte[] eventCreationAsBytes = readBytes(buf, pos);
pos += 4;
if (eventCreationAsBytes != null) {
pos += eventCreationAsBytes.length;
}
byte[] message = readBytes(buf, pos);
pos += 4;
if (message != null) {
pos += message.length;
}
return new ProfilerEvent(eventType, "", "", connectionId, statementId, resultSetId, eventCreationTime, eventDuration, StringUtils.toString(
eventDurationUnits, "ISO8859_1"), StringUtils.toString(eventCreationAsBytes, "ISO8859_1"), null, StringUtils.toString(message, "ISO8859_1"));
}