File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Deprecated methods Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "Deprecated methods" Watch "Deprecated methods" New topic
Author

Deprecated methods

Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
How are we suppose to fix the deprecated methods? I just changed the constructors, that's should be enough right? Or we should do something different?
One specific question: what kind of encoding we should use, if we need it at all?
Jerry Pulley
Ranch Hand

Joined: Sep 19, 2000
Posts: 221
Adrian,
I didn't see any deprecated methods in the c'tors, but maybe my assignment differs from yours. Did you compile with the <code>-deprecated</code> switch? Also, my instructions said nothing about the encoding to use, so I stuck with the default.
Jerry
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
My assignment requires the change of the deprecated methods. I basically change some methods and constructors. As far as encoding, I'm sticking with default, I just want to make sure that it's the right way.
srilatha malip
Greenhorn

Joined: Feb 08, 2001
Posts: 21
I am planning to subclass the given data classes, instead of changing the class itself. In case of changing the deprecated methods, is there any other way instead of replacing the method it self. Since, I don't want to make changes in the data class.
Thanks in Advance,
Srilatha.
joey phillip
Ranch Hand

Joined: Jan 22, 2001
Posts: 40
can any one explain me how to handle the deprecated String Constructor.
how to set the character encoder?
joey
Paul Smiley
Ranch Hand

Joined: Jun 02, 2000
Posts: 244
You're just dealing with ascii text, so it doesn't matter if you use 8859_1 or whatever. I'm certain that the default will be fine.
There is definitely a deprecation in a c'tor but in a standard JDK class, not a suncertify one - I only got 2 overall. Use the -deprecation switch as discussed.
[This message has been edited by Paul Smiley (edited March 15, 2001).]
Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
My assignment requires the change of the deprecated methods. I need to modify readRecord and writeRecord methods.
joey phillip
Ranch Hand

Joined: Jan 22, 2001
Posts: 40
paul/Dilip,
I modified with String(byte[] bytes, int offset, int length) in readRecord method and it works fine.
But I don't know which method and how to use for getBytes method in write record method.
If anyone help me i will really appreciate.
joey
PS whe i try to change with byte[] getBytes() then strange boxes appear in GUI combo box.
Paul Smiley
Ranch Hand

Joined: Jun 02, 2000
Posts: 244
You'll want to use one of the other getBytes() methods - see the API. Hint, you may need to copy the arrays and build your result from there
The boxes on your GUI are nulls - you will need to trim() your strings at some point.
Anil Sadineni
Greenhorn

Joined: Feb 06, 2001
Posts: 20
Hi Friends,
I modified 1 methos with String(byte[] bytes, int offset, int length) in readRecord() method, and i used getChars() insted of using getBytes() Method. After getting the char[] from the method, I am translating the char[] to byte[](byte buffer[]).
Is there anything wrong with my solution Please give me the clarification for that.
Thank you
Bye
Anil.
michael huang
Ranch Hand

Joined: Jul 30, 2000
Posts: 63
Hi,
according to scjd spec, you should document different solution, and show benefit and weakness,
so, friends, tell us your solution.
i have think on it
michael
michael huang
Ranch Hand

Joined: Jul 30, 2000
Posts: 63
hi anil,
can you explain how you translate char[] to byte[],
by the way, i think if you can correctly change char[] to byte[], you solution is ok.
michael
Latha Ganesan
Greenhorn

Joined: Feb 27, 2001
Posts: 12
Hi!,
I have done what Paul Smiley has told, I used getBytes() and copied from temp to buffer(taking care of correct length). Unlike C/C++, Java doesnot have null terminated strings.
Latha
michael huang
Ranch Hand

Joined: Jul 30, 2000
Posts: 63
yes, i think the critical is buffer length
ruilin yang
Ranch Hand

Joined: Feb 25, 2001
Posts: 334
Since you are not dealing with International language the standard encoding: ISO8859-1 is fine.
Alex Zhang
Ranch Hand

Joined: Apr 19, 2001
Posts: 68
I don't know really I am right to have this idea or not
I have a hashtable which use the key of the record for the hashtable key and I use this record key(String) for the lock to apply synchronization within the lock method
I just think if I lock the record no one can use this record concurrently
and I start my modify method with no fear of other modifying the same record
So I have not used the synchronized key word or synchronize block throughout the modify method
Would anyone tell me if there is any problem and error with this
and how to do it better?
 
 
subject: Deprecated methods
 
Threads others viewed
Problems in converting to a Date Object.
GeekWatch hint needed.
What about deprecated method?
Document deprecated methods
Difference between String.copyValueOf(char[]) and String.valueOf(char[])
MyEclipse, The Clear Choice