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[i] = b[i];
}
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 ;
}
}
}
Baby Lion - 02 Oct 2006 02:44 GMT
// Index.java
import java.util.*;
import java.io.*;
import java.lang.*;
import javax.sql.rowset.serial.*;
public class Index {
public int fileid;
public byte pos;
public Index(int id, byte pos)
{
this.fileid = id;
this.pos = pos;
}
}
Baby Lion 写道:
> Hi,Everyone:
> Here is my solotion to change from int to byte[] ,is there a better
[quoted text clipped - 47 lines]
> }
> }
Baby Lion - 02 Oct 2006 02:45 GMT
// Index.java
import java.util.*;
import java.io.*;
import java.lang.*;
import javax.sql.rowset.serial.*;
public class Index {
public int fileid;
public byte pos;
public Index(int id, byte pos)
{
this.fileid = id;
this.pos = pos;
}
}