Results 1 to 4 of 4
- 01-20-2012, 05:54 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 33
- Rep Power
- 0
Is there a way to have a parameter for a method be of type Method() somehow?
Okay, so I have restructured my program to work more efficiently with serialization and saving the files the way I want...but now I need to be able to deserialize the object and use it to get the Class's getter methods. So in my FileIO class I have created a serialize() method, and a few deSerialize() methods with parameters to meet the needs of my program...minus one that would help tremendously. So, here is an example of what I want to do...but it doesn't work with the way I have it setup...I don't even know if it's possible so if it is how would I write the parameter??
Java Code:public void deSerialize( String pFileName, Cabinet pObject, JTextField txf, Method pMethod ) { // my question is about this parameter ^^^^^^^^^^^^^^ try { Cabinet cabinet; File file = new File( pFileName + ".dat" ); FileInputStream inStream = new FileInputStream( file ); ObjectInputStream objectInputFile = new ObjectInputStream( inStream ); cabinet = ( Cabinet ) objectInputFile.readObject(); txf.setText( String.valueOf( cabinet.pMethod() ) ); // This is where the parameter needs to be ^, otherwise I have to make one of these methods for each // method call I want and just write the method in there without it being a variable. inStream.close(); objectInputFile.close(); } catch( FileNotFoundException e ) { } catch( IOException e ) { } catch( ClassNotFoundException e ) { } }
- 01-20-2012, 07:07 PM #2
Re: Is there a way to have a parameter for a method be of type Method() somehow?
Read the API doc for the Method class.
The parameter variable: pMethod is an instance of Method. It is not the name of a method in a class.
To call the method represented by this variable is different than the way you are trying to do it.
- 01-20-2012, 08:41 PM #3
Member
- Join Date
- Jan 2012
- Posts
- 33
- Rep Power
- 0
Re: Is there a way to have a parameter for a method be of type Method() somehow?
I just used that as an example, that is my question. What do I replace Method with to make pMethod work?
- 01-20-2012, 10:34 PM #4
Similar Threads
-
url parameter in open method used in ajax
By pulkit.sharva in forum New To JavaReplies: 0Last Post: 01-14-2012, 07:08 AM -
Get method parameter values using AspectJ?
By gonny in forum New To JavaReplies: 0Last Post: 11-21-2011, 09:16 AM -
Can i Pass a variable as a parameter from one method to other method
By Anagha in forum New To JavaReplies: 18Last Post: 04-18-2011, 05:39 AM -
Class<T> in method parameter
By Onra in forum New To JavaReplies: 4Last Post: 03-14-2011, 12:12 AM -
Can a method take itself as parameter?
By bukake in forum New To JavaReplies: 10Last Post: 09-06-2008, 09:26 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks