Forums Register Login

getBytes() method

+Pie Number of slices to send: Send
Hi Guys,
I replaced the depreciated methods in Data class as requested. If I replace the getBytes() in the writeRecord() method with getBytes() it corrupts the db.db file.
Has anyone found a solution to the problem or did you leave the depreciated method in?
Regards
Fred
+Pie Number of slices to send: Send
 

Originally posted by Fred Barnes:
replace the getBytes() in the writeRecord() method with getBytes()


:roll:
I think you have to replace getBytes(), since it is required in spec.
+Pie Number of slices to send: Send
You can't just replace the method - you have to see what the method is doing and do some extra work to make sure to replace it properly. There are several ways to do it. You don't even have to use getBytes().
+Pie Number of slices to send: Send
It is implied.
There could be more than one way to replace it, but I think the spec means to let you use the replacing method, since it is the recognized way.
+Pie Number of slices to send: Send
Try do a search in the forum...
Rene
+Pie Number of slices to send: Send
You definately have to replace all deprecated methods. In the case of getBytes this can be replaced by getBytes() or getBytes(String).
The getBytes() method uses your default CharacterSet to encode what is writeen to the binary file. Each VM has its own default CharacterSet based on the Operating System. It could be the case that your default character set does not encode the file into a writeable format that is readable later (I have read that if you use OS/390, which uses the EBCDIC character set, there are issues similar to this).
Instead try getBytes(String), where the string is the name of a character set. This forces the program to encode in the necessary character set. US-ASCII should work as the character set. If you decide to go this route, remember that since you are encoding it in US-ASCII, you should also read (decode) it in US-ASCII. This means using a method that allows an encoding parameter to replace the following:
rv[i] = new String(buffer, 0, offset, description[i].getLength());
Whatever you do, just remember to document it with your submission.
+Pie Number of slices to send: Send
Hi Guys,
Thank you for the reply!
However I am still having a problem.
I have replaced the following method
rv[i] = new String(buffer, 0, offset, description[i].getLength());//depreciated one
with
rv[i] = new String(buffer, offset, description[i].getLength());
and
newData[i].getBytes(0, toCopy, buffer, offset);//Depreciated method
with
newData[i].getBytes();
Reading of data works fine! But when I modify the db.db file it corrupts it.
Any advise?
Regards
Fred
+Pie Number of slices to send: Send
Hi Guys,
Sorry I have managed to fix my problem!
Thank you for your replies.
Regards
Fred
+Pie Number of slices to send: Send
Test!
[ January 06, 2003: Message edited by: mo mo ]
+Pie Number of slices to send: Send
getBytes()worked just fine for me.
+Pie Number of slices to send: Send
Hi Aruna,
Did it work fine for writing to the db.db file too?
Regards
Fred
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 957 times.
Similar Threads
what is depreciation of methods
boxes in data
How do you deprecate a class, and/or a method?
Depreciated methods
Threads
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:19:09.