当前位置: 首页>>代码示例>>Java>>正文


Java Byte类代码示例

本文整理汇总了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;
}
 
开发者ID:jpuderer,项目名称:jpuderer-things-drivers,代码行数:20,代码来源:HpmSensor.java

示例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);
}
 
开发者ID:QMXTech,项目名称:OggAudioData,代码行数:25,代码来源:OggAudioData.java

示例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;
}
 
开发者ID:uber,项目名称:auto-value-bundle,代码行数:8,代码来源:AutoValue_TestClassBundled.java

示例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()));
}
 
开发者ID:uber,项目名称:auto-value-bundle,代码行数:29,代码来源:AutoValue_TestClassBundledGCM.java

示例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;
	}
}
 
开发者ID:JozefCeluch,项目名称:thesis-disassembler,代码行数:10,代码来源:TypeInsnNode_instanceof.java

示例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;
}
 
开发者ID:kboyarshinov,项目名称:ActivityScreens,代码行数:12,代码来源:PrimitiveWrappersActivityScreen.java

示例7: encode

import java.lang.Byte; //导入依赖的package包/类
public final void encode(Byte object) throws IOException {
  this.encodeInteger(object);
}
 
开发者ID:achille-roussel,项目名称:mpack-java,代码行数:4,代码来源:MPack.java

示例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;
}
 
开发者ID:Androxyde,项目名称:Flashtool,代码行数:10,代码来源:BytesUtil.java


注:本文中的java.lang.Byte类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。