Author: toad
Date: 2007-11-28 20:13:11 +0000 (Wed, 28 Nov 2007)
New Revision: 16041
Modified:
trunk/freenet/src/freenet/support/Fields.java
Log:
bytesToInts
Modified: trunk/freenet/src/freenet/support/Fields.java
===================================================================
--- trunk/freenet/src/freenet/support/Fields.java 2007-11-28 20:00:49 UTC
(rev 16040)
+++ trunk/freenet/src/freenet/support/Fields.java 2007-11-28 20:13:11 UTC
(rev 16041)
@@ -535,6 +535,20 @@
return x;
}
+ public static int[] bytesToInts(byte[] buf, int offset, int length) {
+ if(length % 4 != 0) throw new IllegalArgumentException();
+ int[] ints = new int[length/4];
+ for(int i=0;i<ints.length;i++) {
+ int x = 0;
+ for(int j=3;j>=0;j--) {
+ int y = (buf[j+offset] & 0xff);
+ x = (x << 8) + y;
+ }
+ ints[i] = x;
+ }
+ return ints;
+ }
+
public static byte[] longToBytes(long x) {
byte[] buf = new byte[8];
for(int j=0;j<8;j++) {