Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is replace the deprecated method getBytes() in this way right ?

Zhou Can
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What i do is :
First change use Char array to get the values , then convert the Char array to a string , finally using String.getBytes() turn the String to byte array .
Codes here :
byte [] buffer = new byte[recordLen];
char [] chars = new char[recordLen];
chars[0] = (char)LIVE_RECORD;
newData[i].getChars(0, toCopy, chars, offset);
String temp = new String(chars);
buffer = temp.getBytes();
Is my choice right ?
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!