📄 arrayutils.java
字号:
/*---------------------------------------------------------------------------
* Copyright (C) 2008 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED PRODUCTS INC. BE LIABLE FOR ANY CLAIM,
* DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated Products,
* Inc. shall not be used except as stated in the Maxim Integrated Products,
* Inc. Branding Policy.
* ---------------------------------------------------------------------------
*/
package com.dalsemi.fs.fat;
public class ArrayUtils
{
public static int getInt(byte[] arr, int offset)
{
return ((arr[offset + 0] & 0x0FF) << 0) |
((arr[offset + 1] & 0x0FF) << 8) |
((arr[offset + 2] & 0x0FF) << 16) |
((arr[offset + 3] & 0x0FF) << 24);
}
public static int getShort(byte[] arr, int offset)
{
return ((arr[offset + 0] & 0x0FF) << 0) |
((arr[offset + 1] & 0x0FF) << 8);
}
public static int getByte(byte[] arr, int offset)
{
return (arr[offset] & 0x0FF);
}
public static void putInt(int val, byte[] arr, int offset)
{
arr[offset + 0] = (byte)(val >> 0);
arr[offset + 1] = (byte)(val >> 8);
arr[offset + 2] = (byte)(val >> 16);
arr[offset + 3] = (byte)(val >> 24);
}
public static void putShort(int val, byte[] arr, int offset)
{
arr[offset + 0] = (byte)(val >> 0);
arr[offset + 1] = (byte)(val >> 8);
}
public static void putByte(int val, byte[] arr, int offset)
{
arr[offset] = (byte)val;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -