Results 1 to 4 of 4
  1. #1
    sarathi is offline Member
    Join Date
    Mar 2009
    Rep Power

    Thumbs down 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.

    given a line as :
    listenerSocket = new ServerSocket(Integer.parseInt(FilePropertyManager. getProperty("TPIN_LISTENER_PORT"," perties")));

    listenerSocket is instance of;
    = is an operator
    new is a key word
    ServerSocket is instance of;
    Integer is a instance of java.lang.Integer
    parseInt is an instance of java.lang.Integer.parseInt
    FilePropertyManager isn an instance of

    can i get any sample code ... for this
    Last edited by sarathi; 03-06-2009 at 04:21 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power


    Quote Originally Posted by sarathi View Post
    parseInt is an instance of java.lang.Integer.parseInt


  3. #3
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Rep Power


    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.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power


    Java Code:
    foo = new Date(42);
    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.

    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

  1. Replies: 1
    Last Post: 01-22-2009, 04:25 PM
  2. Replies: 2
    Last Post: 09-18-2008, 07:30 AM
  3. Creating objects based on a String value
    By lvh in forum New To Java
    Replies: 4
    Last Post: 04-30-2008, 02:00 PM
  4. Find and replace ( in a String
    By hamish10101 in forum New To Java
    Replies: 6
    Last Post: 01-17-2008, 05:51 AM
  5. Replies: 0
    Last Post: 11-20-2007, 04:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts