本文整理匯總了Java中java.nio.MappedByteBuffer.order方法的典型用法代碼示例。如果您正苦於以下問題:Java MappedByteBuffer.order方法的具體用法?Java MappedByteBuffer.order怎麽用?Java MappedByteBuffer.order使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.nio.MappedByteBuffer
的用法示例。
在下文中一共展示了MappedByteBuffer.order方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: if
import java.nio.MappedByteBuffer; //導入方法依賴的package包/類
private ccrcrr bь044C044C044C044C044C(int i) throws IOException, NotEnoughHapticBytesAvailableException {
try {
this.bЭ042DЭЭЭ042D.startTiming();
if (i < this.b042D042DЭЭЭ042D) {
int i2 = this.bЭЭ042DЭЭ042D + i;
int bщ04490449щщщ = bщ04490449щщщ();
int i3 = (i + 1024) + bщ04490449щщщ <= this.b042D042DЭЭЭ042D ? bщ04490449щщщ + 1024 : this.b042D042DЭЭЭ042D - i;
try {
if (i + i3 > this.bЭЭЭ042D042DЭ) {
throw new NotEnoughHapticBytesAvailableException("Not enough bytes available yet.");
} else {
MappedByteBuffer map = this.bЭЭ042DЭ042DЭ.map(MapMode.READ_ONLY, (long) i2, (long) i3);
if (map != null) {
map.order(ByteOrder.BIG_ENDIAN);
ccrcrr rrrrrr_ccrcrr = new ccrcrr();
rrrrrr_ccrcrr.mMappedByteBuffer = map;
if (((bц04460446ц04460446() + bцц0446ц04460446) * bц04460446ц04460446()) % bццц044604460446 != b044604460446ц04460446) {
b04460446цц04460446 = bц04460446ц04460446();
b044604460446ц04460446 = 10;
}
rrrrrr_ccrcrr.mHapticDataOffset = i;
return rrrrrr_ccrcrr;
}
}
} catch (Exception e) {
throw e;
}
}
return null;
} catch (Exception e2) {
throw e2;
}
}
示例2: loadGeodataFile
import java.nio.MappedByteBuffer; //導入方法依賴的package包/類
public static boolean loadGeodataFile(byte rx, byte ry)
{
String fname = "./data/geodata/"+rx+"_"+ry+".l2j";
short regionoffset = (short)((rx << 5) + ry);
_log.info("Geo Engine: - Loading: "+fname+" -> region offset: "+regionoffset+"X: "+rx+" Y: "+ry);
File Geo = new File(fname);
int size, index = 0, block = 0, flor = 0;
FileChannel roChannel = null;
try {
// Create a read-only memory-mapped file
roChannel = new RandomAccessFile(Geo, "r").getChannel();
size = (int)roChannel.size();
MappedByteBuffer geo;
if (Config.FORCE_GEODATA) //Force O/S to Loads this buffer's content into physical memory.
//it is not guarantee, because the underlying operating system may have paged out some of the buffer's data
geo = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, size).load();
else
geo = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, size);
geo.order(ByteOrder.LITTLE_ENDIAN);
if (size > 196608)
{
// Indexing geo files, so we will know where each block starts
IntBuffer indexs = IntBuffer.allocate(65536);
while(block < 65536)
{
byte type = geo.get(index);
indexs.put(block,index);
block++;
index++;
if(type == 0)
index += 2; // 1x short
else if(type == 1)
index += 128; // 64 x short
else
{
int b;
for(b=0;b<64;b++)
{
byte layers = geo.get(index);
index += (layers << 1) + 1;
if (layers > flor)
flor = layers;
}
}
}
_geodataIndex.put(regionoffset, indexs);
}
_geodata.put(regionoffset,geo);
_log.info("Geo Engine: - Max Layers: "+flor+" Size: "+size+" Loaded: "+index);
}
catch (Exception e)
{
e.printStackTrace();
_log.warning("Failed to Load GeoFile at block: "+block+"\n");
return false;
}
return true;
}
示例3: LoadBIN
import java.nio.MappedByteBuffer; //導入方法依賴的package包/類
private boolean LoadBIN() throws IOException {
boolean LoadOK = false;
RandomAccessFile RF = null;
try {
if (_IPDatabasePath.length() > 0) {
RF = new RandomAccessFile(_IPDatabasePath, "r");
final FileChannel InChannel = RF.getChannel();
final MappedByteBuffer _HeaderBuffer = InChannel.map(FileChannel.MapMode.READ_ONLY, 0, 64); // 64 bytes header
_HeaderBuffer.order(ByteOrder.LITTLE_ENDIAN);
_DBType = _HeaderBuffer.get(0);
_DBColumn = _HeaderBuffer.get(1);
_DBYear = _HeaderBuffer.get(2);
_DBMonth = _HeaderBuffer.get(3);
_DBDay = _HeaderBuffer.get(4);
_DBCount = _HeaderBuffer.getInt(5); // 4 bytes
_BaseAddr = _HeaderBuffer.getInt(9); // 4 bytes
_DBCountIPv6 = _HeaderBuffer.getInt(13); // 4 bytes
_BaseAddrIPv6 = _HeaderBuffer.getInt(17); // 4 bytes
_IndexBaseAddr = _HeaderBuffer.getInt(21); //4 bytes
_IndexBaseAddrIPv6 = _HeaderBuffer.getInt(25); //4 bytes
_IPv4ColumnSize = _DBColumn << 2; // 4 bytes each column
_IPv6ColumnSize = 16 + ((_DBColumn - 1) << 2); // 4 bytes each column, except IPFrom column which is 16 bytes
// since both IPv4 and IPv6 use 4 bytes for the below columns, can just do it once here
COUNTRY_POSITION_OFFSET = (COUNTRY_POSITION[_DBType] != 0) ? (COUNTRY_POSITION[_DBType] - 1) << 2 : 0;
REGION_POSITION_OFFSET = (REGION_POSITION[_DBType] != 0) ? (REGION_POSITION[_DBType] - 1) << 2 : 0;
CITY_POSITION_OFFSET = (CITY_POSITION[_DBType] != 0) ? (CITY_POSITION[_DBType] - 1) << 2 : 0;
ISP_POSITION_OFFSET = (ISP_POSITION[_DBType] != 0) ? (ISP_POSITION[_DBType] - 1) << 2 : 0;
PROXYTYPE_POSITION_OFFSET = (PROXYTYPE_POSITION[_DBType] != 0) ? (PROXYTYPE_POSITION[_DBType] - 1) << 2 : 0;
COUNTRY_ENABLED = (COUNTRY_POSITION[_DBType] != 0) ? true : false;
REGION_ENABLED = (REGION_POSITION[_DBType] != 0) ? true : false;
CITY_ENABLED = (CITY_POSITION[_DBType] != 0) ? true : false;
ISP_ENABLED = (ISP_POSITION[_DBType] != 0) ? true : false;
PROXYTYPE_ENABLED = (PROXYTYPE_POSITION[_DBType] != 0) ? true : false;
final MappedByteBuffer _IndexBuffer = InChannel.map(FileChannel.MapMode.READ_ONLY, _IndexBaseAddr - 1, _BaseAddr - _IndexBaseAddr); // reading indexes
_IndexBuffer.order(ByteOrder.LITTLE_ENDIAN);
int Pointer = 0;
// read IPv4 index
for (int x = 0; x < _IndexArrayIPv4.length; x++) {
_IndexArrayIPv4[x][0] = _IndexBuffer.getInt(Pointer); // 4 bytes for from row
_IndexArrayIPv4[x][1] = _IndexBuffer.getInt(Pointer + 4); // 4 bytes for to row
Pointer += 8;
}
if (_IndexBaseAddrIPv6 > 0) {
// read IPv6 index
for (int x = 0; x < _IndexArrayIPv6.length; x++) {
_IndexArrayIPv6[x][0] = _IndexBuffer.getInt(Pointer); // 4 bytes for from row
_IndexArrayIPv6[x][1] = _IndexBuffer.getInt(Pointer + 4); // 4 bytes for to row
Pointer += 8;
}
}
if (_UseMemoryMappedFile) {
CreateMappedBytes(InChannel);
}
else {
DestroyMappedBytes();
}
LoadOK = true;
}
}
catch(IOException Ex) {
throw Ex;
}
finally {
if (RF != null) {
RF.close();
RF = null;
}
}
return LoadOK;
}