• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in getBytes()  RSS feed

Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using the JDK1.3.1. and upgrading the writeRecord() in Data
as the getBytes() has deprecated, so i use getChars() to transform String[] into Char[]
then change it to a String finally use getBytes() change the String to byte[] and write to db.
The operation looks fine.
But the problem is when i search the database again if the file
pointer reach that record again,i got NullPointerException.
Any sugesion will be appreciated.
li li

The code as follow:
int size, space, toCopy;
char [] buffer = new char[recordLen];
buffer[0] = '0';
int offset = 1;
for (int i = 0; i < description.length; i++) {
space = description[i].getLength();
size = newData[i].length();
toCopy = (size <= space) ? size : space;

//newData[i].getBytes(0, toCopy, buffer, offset);
newData[i].getChars(0, toCopy, buffer, offset);

offset += space;
} //end-of-forloop
String temp=new String(buffer);
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!