B
Baby Lion
Hi,Everyone:
Here is my solotion to change from int to byte[] ,is there a better
solution ?
import java.util.*;
import java.io.*;
import java.lang.*;
import javax.sql.rowset.serial.*;
public class Indexes {
public int hashCode;
public String hashString;
public SerialBlob blob;
public byte[] b;
public int length;
public int numberOfIDs;
public int capability;
public ArrayList intArray;
public int lastid; // to make note of last insert ID of intArray
public void DoubleSize()
{
byte temp[] = new byte[capability*2];
for(int i = 0 ; i< length; i++)
{
temp = b;
}
b = temp;
}
public void AddToBytes(int x)
{
int temp = x;
for( int i = 0 ;i<=3 ; i++ ){
b[length++] = new Integer(x & 0xFF).byteValue();
temp = temp >> 8;
}
}
public void IntToByte ()
{
b = new byte [intArray.size()*5+20];
length = 0;
this.capability = intArray.size()*5+20;
for(int i = 0 ;i<intArray.size() ;i++)
{
if (this.capability -5 < length ) { DoubleSize();}
Index temp = (Index)intArray.get(i);
AddToBytes(temp.fileid);
b[length++] = temp.pos ;
}
}
}
Here is my solotion to change from int to byte[] ,is there a better
solution ?
import java.util.*;
import java.io.*;
import java.lang.*;
import javax.sql.rowset.serial.*;
public class Indexes {
public int hashCode;
public String hashString;
public SerialBlob blob;
public byte[] b;
public int length;
public int numberOfIDs;
public int capability;
public ArrayList intArray;
public int lastid; // to make note of last insert ID of intArray
public void DoubleSize()
{
byte temp[] = new byte[capability*2];
for(int i = 0 ; i< length; i++)
{
temp = b;
}
b = temp;
}
public void AddToBytes(int x)
{
int temp = x;
for( int i = 0 ;i<=3 ; i++ ){
b[length++] = new Integer(x & 0xFF).byteValue();
temp = temp >> 8;
}
}
public void IntToByte ()
{
b = new byte [intArray.size()*5+20];
length = 0;
this.capability = intArray.size()*5+20;
for(int i = 0 ;i<intArray.size() ;i++)
{
if (this.capability -5 < length ) { DoubleSize();}
Index temp = (Index)intArray.get(i);
AddToBytes(temp.fileid);
b[length++] = temp.pos ;
}
}
}