本文整理汇总了Java中org.apache.harmony.luni.util.Util.convertUTF8WithBuf方法的典型用法代码示例。如果您正苦于以下问题:Java Util.convertUTF8WithBuf方法的具体用法?Java Util.convertUTF8WithBuf怎么用?Java Util.convertUTF8WithBuf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.harmony.luni.util.Util
的用法示例。
在下文中一共展示了Util.convertUTF8WithBuf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decodeUTF
import org.apache.harmony.luni.util.Util; //导入方法依赖的package包/类
private static String decodeUTF(int utfSize, DataInput in) throws IOException {
byte[] buf = new byte[utfSize];
char[] out = new char[utfSize];
in.readFully(buf, 0, utfSize);
return Util.convertUTF8WithBuf(buf, out, 0, utfSize);
}
示例2: readUTF
import org.apache.harmony.luni.util.Util; //导入方法依赖的package包/类
public String readUTF() throws IOException {
ByteOrder byteOrder = getByteOrder();
setByteOrder(ByteOrder.BIG_ENDIAN);
final int size = readUnsignedShort();
final byte[] buf = new byte[size];
final char[] out = new char[size];
readFully(buf, 0, size);
setByteOrder(byteOrder);
//return new DataInputStream(new ByteArrayInputStream(buff)).readUTF();
return Util.convertUTF8WithBuf(buf, out, 0, size);
}
示例3: decodeUTF
import org.apache.harmony.luni.util.Util; //导入方法依赖的package包/类
String decodeUTF(int utfSize) throws IOException {
byte[] buf;
char[] out = null;
boolean makeBuf = true;
/*
* Try to avoid the synchronization -- if we get a stale value for
* useShared then there is no foul below, but those that sync on the
* lock must see the right value.
*/
if (utfSize <= MAX_BUF_SIZE && useShared) {
synchronized (cacheLock) {
if (useShared) {
useShared = false;
makeBuf = false;
}
}
}
if (makeBuf) {
buf = new byte[utfSize];
out = new char[utfSize];
} else {
/*
* Need to 'sample' byteBuf and charBuf before using them because
* they are not protected by the cacheLock. They may get out of sync
* with the static and one another, but that is ok because we
* explicitly check and fix their length after sampling.
*/
buf = byteBuf;
if (buf.length < utfSize) {
buf = byteBuf = new byte[utfSize];
}
out = charBuf;
if (out.length < utfSize) {
out = charBuf = new char[utfSize];
}
}
readFully(buf, 0, utfSize);
String result;
result = Util.convertUTF8WithBuf(buf, out, 0, utfSize);
if (!makeBuf) {
/*
* Do not synchronize useShared on cacheLock, it will make it back
* to main storage at some point, and no harm until it does.
*/
useShared = true;
}
return result;
}