Results 1 to 4 of 4
- 03-06-2009, 04:16 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 1
- Rep Power
- 0
Find java objects in a given string.
am trying to find out, what are the java objects in a given string. Given java source file as an in put to a file reader. i wil read line by line of the given file and list out the java objects in a given line and want to find out the base class of the same.
example:
given a line as :
listenerSocket = new ServerSocket(Integer.parseInt(FilePropertyManager. getProperty("TPIN_LISTENER_PORT","TPINListener.pro perties")));
listenerSocket is instance of java.net.ServerSocket;
= is an operator
new is a key word
ServerSocket is instance of java.net.ServerSocket;
Integer is a instance of java.lang.Integer
parseInt is an instance of java.lang.Integer.parseInt
FilePropertyManager isn an instance of java.io.FilePropertyManager
can i get any sample code ... for thisLast edited by sarathi; 03-06-2009 at 04:21 AM.
- 03-06-2009, 08:04 AM #2
- 03-06-2009, 08:34 AM #3
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
parseInt is no Object and can therefore not be an instance :o It's a method.
I die a little on the inside...
Every time I get shot.
- 03-06-2009, 08:42 AM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,546
- Rep Power
- 11
In this line of code there is no way of telling whether the Date bit refers to java.util.Date or java.sql.Date or to my own subclass of java.util.Date.Java Code:foo = new Date(42);
Likewise nothing in the line would prepare you for the fact that foo "is" an Integer. (Yes, the code doesn't compile...)
The point of all this is to suggest that whatever you mean by "instance of", there is simply no way to get that information from a single line. You're going to have to write something like javac.exe that compiles whole .java files. But this is the "New to Java" forum, so perhaps this task might be better left for a week or so.
Similar Threads
-
read txt file,with some records, create objects and store objects in tables of a db.
By stamv in forum JDBCReplies: 1Last Post: 01-22-2009, 04:25 PM -
Error: cannot resolve symbol' on Person (java.lang.String, java.lang.String)
By baltimore in forum New To JavaReplies: 2Last Post: 09-18-2008, 07:30 AM -
Creating objects based on a String value
By lvh in forum New To JavaReplies: 4Last Post: 04-30-2008, 02:00 PM -
Find and replace ( in a String
By hamish10101 in forum New To JavaReplies: 6Last Post: 01-17-2008, 05:51 AM -
Using java.util.Scanner to search for a String in a String
By Java Tip in forum Java TipReplies: 0Last Post: 11-20-2007, 04:59 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks