Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

getBytes() deprecated method.. Am I missing something ?

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To change deprecated getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) method
in writeRecord() of the Data class, I changed the source code FROM
for (int i = 0; i < description.length; i++) {
space = description[i].getLength();
size = newData[i].length();
toCopy = (size <= space) ? size :space;

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

offset += space;
}
TO
for (int i = 0; i < description.length; i++) {
space = description[i].getLength();
size = newData[i].length();
toCopy = (size <= space) ? size : space;
byte[] tmpBuffer = newData[i].getBytes();
System.arraycopy(tmpBuffer, 0, buffer, offset, toCopy);

offset += space;
}
Did I do anything wrong here ? Am I missing something ?
It works fine though...But, I am not sure whether it
works in all the cases !!!
[ April 11, 2002: Message edited by: Krishna Varma Adluru ]
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks good to me. Why do you think it won't work for all cases?
 
Krishna Varma Adluru
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some people were saying that we need to use
ASCII encoding ...
I am using default encoding
Regards,
Krishna Varma Adluru
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Krishna,
I'm using default also. Mark used default, many others used UTF-8 (which as Mark pointed out is the default), and I'm only aware of a few who used ASCII.
Michael Morris
[ April 11, 2002: Message edited by: Michael Morris ]
[ April 11, 2002: Message edited by: Michael Morris ]
 
Krishna Varma Adluru
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone
Regards,
Krishna
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic