• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

deprecated methods

 
Rahel Luethy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, i know that i can make a "search" and find the complete code and just copy/paste it in order to solve the deprecation problem nevertheless, i'll be happy to know if there are any alternatives...
in order to get rid of the deprecated calls i'm using a ByteArrayInputStream/-OutputStream. one great advantage is that you don't have to manually control the "offset" pointer anymore. moreover, it somehow encapsulates the low-level-byte-shuffling-hassle... however, after browsing this forum i'm somehow sceptical about my solution since nobody else is doing anything alike
 
Thomas Mueller
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey rahel
I did this:
... readRecord(){ ...
rv[i] = new String(buffer, offset, description[i].getLength(),ENCODING);
...
instead of this:
//rv[i] = new String(buffer, 0, offset, description[i].getLength());(
And for the method writeRecord I changed this:
...
//newData[i].getBytes(0, toCopy, buffer, offset);
...
to this:
...
byte [] encodedBuffer = null;
...
encodedBuffer = newData[i].getBytes(ENCODING);
for (int j = 0;j < encodedBuffer.length && j < toCopy ;j++)
{
buffer[j + offset] = encodedBuffer[j];
}
...
I tried to ceep the solution as close as possible to the original code.
It works, but I'm not shure if use the correct encoding.
...
private static final String ENCODING = "UTF-8";
...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic