Here you can find the source of getBoolean(ByteBuffer bytes)
public static boolean getBoolean(ByteBuffer bytes)
//package com.java2s; /******************************************************************************* * Copyright 2012 Apigee Corporation//from w w w.j a va2 s . com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ import java.nio.ByteBuffer; public class Main { /** * @param bytes * @return */ public static boolean getBoolean(byte[] bytes) { return bytes[0] != 0; } public static boolean getBoolean(ByteBuffer bytes) { return bytes.slice().get() != 0; } /** * @param bytes * @param offset * @return */ public static boolean getBoolean(byte[] bytes, int offset) { return bytes[offset] != 0; } public static boolean getBoolean(Object obj) { if (obj instanceof Boolean) { return (Boolean) obj; } else if (obj instanceof String) { return Boolean.parseBoolean((String) obj); } else if (obj instanceof Number) { return ((Number) obj).longValue() > 0; } return false; } }