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
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().
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.
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.
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