Guest User

Untitled

a guest
Jul 19th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1.     public int getAddressFromIndex(int index) throws IOException {
  2.         int tIndex = 0;
  3.        
  4.         for(int n = 0; n < 32; n++) {
  5.             channel.position(tIndex);
  6.            
  7.             ByteBuffer buf = ByteBuffer.allocate(8);
  8.             channel.read(buf);
  9.            
  10.             buf.rewind();
  11.            
  12.             int i1 = buf.getInt();
  13.             int i2 = buf.getInt(); 
  14.            
  15.             tIndex = ((index & (1 << (31 - n))) != 0) ? i2 : i1;   
  16.            
  17.             if(tIndex == 0) {
  18.                 return 0;
  19.             }
  20.         }
  21.        
  22.         return tIndex;
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment