• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getBytes() deprecated method.. Am I missing something ?

 
Krishna Varma Adluru
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To change deprecated getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) method
in writeRecord() of the Data class, I changed the source code FROM
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);

offset += space;
}
TO
for (int i = 0; i < description.length; i++) {
space = description[i].getLength();
size = newData[i].length();
toCopy = (size <= space) ? size : space;
byte[] tmpBuffer = newData[i].getBytes();
System.arraycopy(tmpBuffer, 0, buffer, offset, toCopy);

offset += space;
}
Did I do anything wrong here ? Am I missing something ?
It works fine though...But, I am not sure whether it
works in all the cases !!!
[ April 11, 2002: Message edited by: Krishna Varma Adluru ]
 
Rama Ituarte
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks good to me. Why do you think it won't work for all cases?
 
Krishna Varma Adluru
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some people were saying that we need to use
ASCII encoding ...
I am using default encoding
Regards,
Krishna Varma Adluru
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Krishna,
I'm using default also. Mark used default, many others used UTF-8 (which as Mark pointed out is the default), and I'm only aware of a few who used ASCII.
Michael Morris
[ April 11, 2002: Message edited by: Michael Morris ]
[ April 11, 2002: Message edited by: Michael Morris ]
 
Krishna Varma Adluru
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone
Regards,
Krishna
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic