• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

is this deprecate modification right?

 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Old Codes:
newData[i].getBytes(0, toCopy, buffer, offset);
New Codes:
System.arraycopy(newData[i].getBytes(),0,buffer,offset,toCopy);
Old Codes:
rv[i] = new String(buffer, 0, offset, description[i].getLength());
New Codes:
rv[i] = new String(buffer,offset, description[i].getLength(),"US-ASCII");
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Almost...
In the first place, why don't you address the CharSetName in the getBytes-method?!
Hope it helps
Detlev
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which charsetname is right?
US-ASCII
OR UTF-8?
 
Detlev Beutner
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The given DataBase follows at least US-ASCII (you have also used this in the other case), so US-ASCII should be ok!
Hope it helps
Detlev
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Iam using the following to remove the depricated methods
new String(buffer,offset,description[i].length) here as per the sun's API documentation i observed that this uses native enoding. Please help me if iam wrong.
regards,
rameshkumar
 
Detlev Beutner
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Ramesh
As I stated in some other topic, using the platforms encoding brings you to fall running for example on an OS/390 (using EBCDIC). You would not be able to read any senseful data from the database. (In fact, on Windows etc. it would work, but it's just luck...)
Hope it helps
Detlev
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
db.write(buffer);
Is my choice right ?
 
Zhou Can
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
up...
Need ur help .
reply
    Bookmark Topic Watch Topic
  • New Topic