本文整理匯總了Java中gnu.lists.ByteVector類的典型用法代碼示例。如果您正苦於以下問題:Java ByteVector類的具體用法?Java ByteVector怎麽用?Java ByteVector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ByteVector類屬於gnu.lists包,在下文中一共展示了ByteVector類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readByteVector
import gnu.lists.ByteVector; //導入依賴的package包/類
public int readByteVector(ByteVector bvector, int offset, int count)
throws IOException {
int rcount = 0;
while (pos < limit) {
if (rcount == count)
return rcount;
int r = read();
if (r < 0)
return rcount > 0 ? rcount : -1;
bvector.setByteAt(offset+(rcount++), (byte) r);
}
if (rcount > 0)
return rcount;
if (! bfill())
return -1;
int n = blimit - bpos;
if (n > count)
n = count;
bvector.copyFrom(bbuffer, bpos, offset, n);
bpos += n;
return n;
}
示例2: getInputStreamFrom
import gnu.lists.ByteVector; //導入依賴的package包/類
public static InputStream getInputStreamFrom(Object val) {
if (val instanceof ByteVector)
return ((ByteVector) val).getInputStream();
if (val instanceof Process)
return ((Process) val).getInputStream();
if (val instanceof byte[])
return new ByteArrayInputStream((byte[]) val);
if (val instanceof CharSequence)
// FIXME should be able to override Charset
// FIXME can perhaps optimize for CharSeq by using writeTo.
return new ByteArrayInputStream(((CharSequence) val).toString().getBytes());
throw new ClassCastException("invalid input");
}