Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Karthik Jayaprakasham
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whats the best way to change the implementation for this..
The Java API says use getBytes() but this would return me all the bytes wont it, not the subsections...
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Karthik,
You are right that just calling getBytes will return all bytes. But there is another method in the String class you can call first which will just return a substring of the provided string. Then you can call getBytes on that substring.
Regards, Andrew
 
Ian Roberts
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Andrew is right. Although at the time I incorrectly thought nothing was documented (a bit silly but there you are), I would have a good look at the Sun Java API documentation website that basically provides a solution for you. It is a little tricky but, as Andrew has said, there is a method that behaves as a intermediate step. The solution will come, it took me a couple of hours of checking and testing to be confident that it was that easy (when you find it you will be surprised) - I was looking for something that I believed must be far more difficult to fix.
Good luck.
Ian R.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic