com.mucommander.io
Class ByteUtils
java.lang.Object
com.mucommander.io.ByteUtils
public class ByteUtils
- extends java.lang.Object
This class provides convenience static methods that operate on bits and bytes.
- Author:
- Maxence Bernard
|
Method Summary |
static int |
setBit(int i,
int bit,
boolean enabled)
Sets/unsets a bit in the given integer. |
static java.lang.String |
toHexString(byte[] bytes)
Returns an hexadecimal string representation of the given byte array, where each byte is represented by two
hexadecimal characters and padded with a zero if its value is comprised between 0 and 15 (inclusive). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ByteUtils
public ByteUtils()
setBit
public static int setBit(int i,
int bit,
boolean enabled)
- Sets/unsets a bit in the given integer.
- Parameters:
i - the permission intbit - the bit to setenabled - true to enable the bit, false to disable it
- Returns:
- the modified permission int
toHexString
public static java.lang.String toHexString(byte[] bytes)
- Returns an hexadecimal string representation of the given byte array, where each byte is represented by two
hexadecimal characters and padded with a zero if its value is comprised between 0 and 15 (inclusive).
As an example, this method will return "6d75636f0a" when called with the byte array {109, 117, 99, 111, 10}.
- Parameters:
bytes - the array of bytes for which to get an hexadecimal string representation
- Returns:
- an hexadecimal string representation of the given byte array
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard