/*
* This file is part of JSTUN.
*
* Copyright (c) 2005 Thomas King <king@t-king.de> - All rights
* reserved.
*
* This software is licensed under either the GNU Public License (GPL),
* or the Apache 2.0 license. Copies of both license agreements are
* included in this distribution.
*/
class Main{
publicstaticfinalbyte[] integerToFourBytes(int value) throws UtilityException {
byte[] result = newbyte[4];
if ((value > Math.pow(2,63)) || (value < 0)) {
thrownew UtilityException("Integer value " + value + " is larger than 2^63");
}
result[0] = (byte)((value >>> 24) & 0xFF);
result[1] = (byte)((value >>> 16) & 0xFF);
result[2] = (byte)((value >>> 8) & 0xFF);
result[3] = (byte)(value & 0xFF);
return result;
}
}
class UtilityException extends Exception {
privatestaticfinallong serialVersionUID = 3545800974716581680L;
UtilityException(String mesg) {
super(mesg);
}
}