Kaito
how to use StringTokenizer to retrieve the class name, attributes name and methods name from the Java Source Code
0 Answer(s)      4 years and 5 months ago
Posted in : Java Beginners

hi, I have done a program whereby it can read a Java file and then tokenize them into tokens. However, I am facing one problem which is retrieve the Class Name, Attributes Name and Methods Names only from the source code. Can anyone help me to solve it? Below are my portion of codes. Thx!

import java.util.*;
import java.io.*;

public class Abc {
  private String filename;
  private int count;

  Abc( String name ) {
     filename = name; 
     count = 0;
  }
   public void readFile() throws IOException{
     String line;
     System.out.println( "File: " + filename ); 

     Scanner sc = new Scanner( new File ( filename )  );
     while (sc.hasNextLine() ) {
        line = sc.nextLine();       
        count++;    
        tokenize(line);
     }
   }


  public void tokenize(String line) throws IOException {

    StringTokenizer st = new StringTokenizer( line, "; "  );
         while (st.hasMoreTokens()) {


        System.out.println("This is a token <" + st.nextToken() + ">");

     }
  }

  public static void main (String args [])throws Exception{
    Abc x; 
    x = new Abc ( "Abc.java" ); 
    x.readFile();
  }
}
Advertisement
View Answers









Related Tutorials/Questions & Answers:
how to use StringTokenizer to retrieve the class name, attributes name and methods name from the Java Source Code
how to use StringTokenizer to retrieve the class name, attributes name and methods name from the Java Source Code  hi, I have done a program whereby... one problem which is retrieve the Class Name, Attributes Name and Methods Names
Java class name and file name are different
Java class name and file name are different  Can we run a Java program having class name and file name different?   Hi Friend, No, you can't. It is necessary to save the java file with its class name otherwise
Advertisements
java how to get domain name from url
java how to get domain name from url  How to get the domain name from a url string? Example program in java for "how to get domain name from url" Thanks   Hi, You can use the following example code: URL linkURL
class name
class name  what is the class name of circle.java   how do i complie my jdk file, what happen s if i put in the correct commands and it still does not complie, what do i do next
Name
all the human names which starts from B.   Java show all names that starts with particular character The give code takes the input character from...Name  make a program that take a input from user in alphabet and show
Difference between class,name,id attributes in each JSP tag
Difference between class,name,id attributes in each JSP tag  Can i know the difference between class,name,id attributes in each JSP tags.................. These 3 are only used for reference ..... And what are the differernces
class name
class name  how to create a class named box thaT INCLUDES integer data fields for length,width,and height, include three contructors that require one,two,three arguments
How to extract name,surname, doamin name from mailid
How to extract name,surname, doamin name from mailid  Hi sir How to extract name,surname, doamin name from mailid using java coding? for example... name as java plz tel me
How to get month name from date(like-25/06/2012) using java?
How to get month name from date(like-25/06/2012) using java?  How to get month name from date(like-25/06/2012) using java
Retrieving the class name through Reflection API
Retrieving the class name through Reflection API       A more generic way, how to retrieve the name... the reference of the class java.util.Integer.class to it. Now retrieve the class name
Get computer name in java
Get computer name in java       We can get the computer name by the java code program. For getting computer name we have used java.net.InetAddress class. We will use static
how to get java path name
How to write script in Java  <html> <head> <script>alert('ok')</script> </head> </Html>
How to retrieve file name and path of an excel spreadsheet imported into Oracle Database
How to retrieve file name and path of an excel spreadsheet imported into Oracle... Oracle database and I want to know how to retrieve the path of the file... of the spreadsheets imported (so I would know the location of the original source file
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
Get Class Name
Get Class Name       In the example given below we will learn how to get name of the particular class with package name. getName() method returns fully qualified name
Java example to get Object class name at runtime
Java example to get Object class name at runtime       java get Object class name In java.... Here is the full java code of program which will be getting the object's class
why java file save as its class name
why java file save as its class name  hi,this is subbareddy vajrala.my doubt is why java files save as its class names
retrieve Dept Name from table dept and retrieve list of employee from emp table for that dept in combobox
retrieve Dept Name from table dept and retrieve list of employee from emp table... 10 in Dept Number Textbox and onblur event,it should retrieve Dept Name from... retrieve data from database from table1 and display it in another textbox and from
Java Program MY NAME
Java Program MY NAME   Write a class that displays your first name...() { }, Then, method main should create an object of your class, then call the methods... should have the lines of code needed to display that letter in a method
Use of name() function in XPath
XPathName class to retrieve name of different nodes according to queries: Here... Use of name() function in XPath   ... tutorial we have studied about how to use count() function in  XPath query
Java program to get class name without package
Java program to get class name without package ... example which describes you that how you can get the class name without package.... As a result we will finally get the class name without package.  In this code
My name, java project
My name, java project  Write a class that displays your first name... letter being displayed should have the lines of code needed to display that letter in a method with the following name (for example, for letter A, public
My name, java project
My name, java project  Write a class that displays your first name... letter being displayed should have the lines of code needed to display that letter in a method with the following name (for example, for letter A, public
Java Get Host Name
; In this Example you will learn how to get host name in Java. Go through the below given code to understand how it works and gets the host name...; Java code to get host name import java.net.
How to get the Day name
How to get the Day name  Hi, I am a beginner in Java and new to this web world as well. have a requirement to implement in my assignment project as below: We need to add the days in input date such that it create the date
personal name aliase from the web
personal name aliase from the web  enter the name to search result in internet connection
Java file get name
Java file get name In this section, you will learn how to get the name... the name of the file. Here is the code: import java.io.*; public class... name is: " + st); } } Through the method getName() of File class, you can