Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

deprecated methods

 
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
 
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";
...
 
We don't have time for this. We've gotta save the moon! Or check this out:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic