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

is this deprecate modification right?

 
Sean Li
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • 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");
 
Detlev Beutner
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • 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
 
Jeff Song
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Ramesh kumaar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
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();
db.write(buffer);
Is my choice right ?
 
Zhou Can
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
up...
Need ur help .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic