jclass
Class util

java.lang.Object
  |
  +--jclass.util

public class util
extends java.lang.Object

Stupid class that contains various simple but useful methods.

Written: Radu Sion
Version: 0.24
Source: util.java

Visit Smart Software 


Constructor Summary
util()
           
 
Method Summary
static int bytes2int(byte[] data)
          Creates a integer out of four bytes using the big endian technique
static byte[] bytescat(byte[] b1, byte[] b2)
          Appends b2 to b1 and returns the result.
static byte[] bytescut(int i1, int i2, byte[] b)
          Cuts between i1 and i2 in b (inclusive) and returns the result.
static void closeInputStream(java.io.InputStream ss)
           
static void closeOutputStream(java.io.OutputStream ss)
           
static void closeSocket(java.net.Socket ss)
           
static int getDigit(int position, long value)
          Returns the named digit from a long starting with digit 0 at the rightmost position.
static byte[] int2bytes(int data)
          Returns a four bytes array representation of a integer using big endian technique.
static int pow_int(int a, int b)
           
static long pow_long(long a, long b)
           
static java.lang.String readLine(java.io.InputStream is)
nbsp;         The method bellow is adapted from the jdk102 DataInputStream source and reads from a InputStream a whole line, that has been terminated by a \n, \r, \r\n or EOF.
static int stringWidth(java.lang.String str, java.awt.FontMetrics fm)
          Returns the pixel width of the specified string using the specified fontmetric.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

util

public util()
Method Detail

pow_int

public static int pow_int(int a,
                          int b)

pow_long

public static long pow_long(long a,
                            long b)

closeInputStream

public static void closeInputStream(java.io.InputStream ss)

closeOutputStream

public static void closeOutputStream(java.io.OutputStream ss)

closeSocket

public static void closeSocket(java.net.Socket ss)

bytescat

public static byte[] bytescat(byte[] b1,
                              byte[] b2)
Appends b2 to b1 and returns the result.

bytescut

public static byte[] bytescut(int i1,
                              int i2,
                              byte[] b)
Cuts between i1 and i2 in b (inclusive) and returns the result. Assuming i1

bytes2int

public static int bytes2int(byte[] data)
Creates a integer out of four bytes using the big endian technique

int2bytes

public static byte[] int2bytes(int data)
Returns a four bytes array representation of a integer using big endian technique.

getDigit

public static int getDigit(int position,
                           long value)
Returns the named digit from a long starting with digit 0 at the rightmost position. No parameter checkings are done. If some error detected then return is zero !!!

stringWidth

public static int stringWidth(java.lang.String str,
                              java.awt.FontMetrics fm)
Returns the pixel width of the specified string using the specified fontmetric.
Returns:
0 in case of error, pozitive otherwise

readLine

public static java.lang.String readLine(java.io.InputStream is)
                                 throws java.io.IOException
The method bellow is adapted from the jdk102 DataInputStream source and reads from a InputStream a whole line, that has been terminated by a \n, \r, \r\n or EOF.

The ideea here is to be able to read a line without having to create any new buffered readers or so which make it impossible afterwards to use the initial inputstream normal anymore
Returns:
a String copy of the read line.