本文整理汇总了Java中java.lang.Byte类的典型用法代码示例。如果您正苦于以下问题:Java Byte类的具体用法?Java Byte怎么用?Java Byte使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Byte类属于java.lang包,在下文中一共展示了Byte类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processDataFrame
import java.lang.Byte; //导入依赖的package包/类
void processDataFrame(byte[] dataframe) {
if (DEBUG) Log.d(TAG, "dataframe: " + bytesToHex(dataframe));
int checksum = (Byte.toUnsignedInt(dataframe[30]) << 8) + Byte.toUnsignedInt(dataframe[31]);
int calculatedChecksum = 0;
for (int i = 0; i < 30; i++) {
calculatedChecksum += Byte.toUnsignedInt(dataframe[i]);
}
if (checksum != calculatedChecksum) {
Log.e(TAG, "Checksum error in data frame. Ignoring.");
return;
}
// Assign PM2.5 and PM10 values
mPm25 = (Byte.toUnsignedInt(dataframe[6]) << 8) + Byte.toUnsignedInt(dataframe[7]);
mPm10 = (Byte.toUnsignedInt(dataframe[8]) << 8) + Byte.toUnsignedInt(dataframe[9]);
// Clear exception
mLastException = null;
}
示例2: OggAudioData
import java.lang.Byte; //导入依赖的package包/类
private OggAudioData(InputStream is) throws Exception {
PushbackInputStream stream = new PushbackInputStream(is, 20000000);
long size = 0;
int bt = 0;
ArrayList<Byte> btList = new ArrayList<Byte>();
while (bt != -1) {
bt = stream.read();
if (bt == -1) {
break;
}
btList.add(new Byte((byte) bt));
size++;
}
byte[] reset = new byte[btList.size()];
int j=0;
for(Byte y: btList) {
reset[j++] = y.byteValue();
}
stream.unread(reset);
initValues(stream, size);
}
示例3: toPrimitive
import java.lang.Byte; //导入依赖的package包/类
public static byte[] toPrimitive(Byte[] byteParam) {
byte[] bytes = new byte[byteParam.length];
for (int i = 0; i < byteParam.length; i++) {
bytes[i] = byteParam[i];
}
return bytes;
}
示例4: unbundle
import java.lang.Byte; //导入依赖的package包/类
public static TestClassBundledGCM unbundle(Bundle bundle, Gson gson) {
return new AutoValue_TestClassBundledGCM(
bundle,
Byte.parseByte(bundle.getString("some_byte")),
Boolean.parseBoolean(bundle.getString("some_boolean")),
Short.parseShort(bundle.getString("some_short")),
Integer.parseInt(bundle.getString("some_int")),
Long.parseLong(bundle.getString("some_long")),
bundle.getString("some_char").charAt(0),
Float.parseFloat(bundle.getString("some_float")),
Double.parseDouble(bundle.getString("some_double")),
bundle.getString("some_string"),
bundle.getString("some_char_sequence"),
gson.fromJson(bundle.getString("some_parcelable"), Parcelable.class),
gson.fromJson(bundle.getString("some_parcelable_array_list"), new com.google.common.reflect.TypeToken<java.util.ArrayList<Parcelable>>(){}.getType()),
gson.fromJson(bundle.getString("some_parcelable_sparse_array"), new com.google.common.reflect.TypeToken<android.util.SparseArray<Parcelable>>(){}.getType()),
gson.fromJson(bundle.getString("some_serializable"), Serializable.class),
gson.fromJson(bundle.getString("some_integer_array_list"), new com.google.common.reflect.TypeToken<java.util.ArrayList<Integer>>(){}.getType()),
gson.fromJson(bundle.getString("some_string_array_list"), new com.google.common.reflect.TypeToken<java.util.ArrayList<String>>(){}.getType()),
gson.fromJson(bundle.getString("some_char_sequence_array_list"), new com.google.common.reflect.TypeToken<java.util.ArrayList<CharSequence>>(){}.getType()),
toPrimitive(gson.fromJson(bundle.getString("some_byte_array"), Byte[].class)),
toPrimitive(gson.fromJson(bundle.getString("some_short_array"), Short[].class)),
toPrimitive(gson.fromJson(bundle.getString("some_char_array"), Character[].class)),
toPrimitive(gson.fromJson(bundle.getString("some_float_array"), Float[].class)),
gson.fromJson(bundle.getString("some_unknown_object"), new com.google.common.reflect.TypeToken<UnknownObject>(){}.getType()),
gson.fromJson(bundle.getString("some_unknown_object_list"), new com.google.common.reflect.TypeToken<ArrayList<UnknownObject>>(){}.getType()),
gson.fromJson(bundle.getString("test_enum"), new com.google.common.reflect.TypeToken<TestEnum>(){}.getType()));
}
示例5: isInstance
import java.lang.Byte; //导入依赖的package包/类
public void isInstance() {
int localInt = 1;
boolean bool = this instanceof Object && localInt < Byte.MIN_VALUE;
if ("" instanceof Object) {
localInt = 2;
} else {
localInt = -1;
}
}
示例6: PrimitiveWrappersActivityScreen
import java.lang.Byte; //导入依赖的package包/类
public PrimitiveWrappersActivityScreen(Character field1, Integer field2, Double field3, Float field4, Boolean field5,
Short field6, Byte field7, Long field8) {
this.field1 = field1;
this.field2 = field2;
this.field3 = field3;
this.field4 = field4;
this.field5 = field5;
this.field6 = field6;
this.field7 = field7;
this.field8 = field8;
}
示例7: encode
import java.lang.Byte; //导入依赖的package包/类
public final void encode(Byte object) throws IOException {
this.encodeInteger(object);
}
示例8: getBytes
import java.lang.Byte; //导入依赖的package包/类
public static Byte[] getBytes(String hexString) {
int len = hexString.length();
Byte[] data = new Byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(hexString.charAt(i), 16) << 4)
+ Character.digit(hexString.charAt(i+1), 16));
}
return data;
}