Home Answers Viewqa Java-Beginners how to use StringTokenizer to retrieve the class name, attributes name and methods name from the Java Source Code

 
 


Kaito
how to use StringTokenizer to retrieve the class name, attributes name and methods name from the Java Source Code
0 Answer(s)      2 years and 4 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();
  }
}
View Answers









Related Pages:
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
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
Set the mapping name
the method name to call as a query string parameter, or use an alias. ... are the disadvantages?  The need to extend the class from EventDispatchAction and hence cannot extend our class from a custom base class
Combine Name
Java: Example - CombineName The following program has two text fields, one for a first name and one for a last name. When the button is pressed, it formats them in the result field in the standard last name comma first name style
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
Set the mapping name
; How to create one?  1. Extend your action class from... the common code part to this BaseAction and extended my action class from... and the same Action class name can be used.  What are the disadvantages
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
Programming - Transform Name - GUI 0
Java: Programming - Transform Name - GUI 0 Write a GUI program to redisplay a name, possibly transformed. This Java program will reformat a user's name... be good extra credit for this program. You can easily use the Java functions
Getting the method name used in the Application
;    In this section we describe how to retrieve method... the use of the getMethods() method in more detail. Define a class named "... of java.util.Integer.class into it. Now retrieve the method name by using the getMethods
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
CORE JAVA get middle name
CORE JAVA get middle name  hello sir...how to get middle name using...; The given code accepts the name from the console and find the middle character from the name. import java.util.*; class GetMiddleCharacter { public
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
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
Problems in Stringtokenizer
; //node no is assigned str1=new StringTokenizer(str.nextToken()," "); use...Problems in Stringtokenizer  hi here is my code import java.util.*; import java.io.*; import java.util.Scanner; class Node { public boolean marked
Problems in Stringtokenizer
; //node no is assigned str1=new StringTokenizer(str.nextToken()," "); use...Problems in Stringtokenizer  hi here is my code import java.util.*; import java.io.*; import java.util.Scanner; class Node { public boolean marked
Problems in Stringtokenizer
; //node no is assigned str1=new StringTokenizer(str.nextToken()," "); use...Problems in Stringtokenizer  hi here is my code import java.util.*; import java.io.*; import java.util.Scanner; class Node { public boolean marked
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
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
name of year in chinese
name of year in chinese   hello my name kiemtheng i'm come from Cambodia, i would to write java programming to calculate a name of year for each birthday in Chinese but i dont know how to do.   import java.util.
Find Name of Excel Sheet
; copied  from class.   public static final short sid: The sid... Find Name of Excel Sheet       In this program we are going to find the name of an excel
name of year in chinese
name of year in chinese   hello my name kiemtheng i'm come from Cambodia, i would to write java programming to calculate a name of year for each birthday in Chinese but i dont know how to do.   import java.util.
Java Get File Name
Java Get File Name       In this section, you will study how to obtain the name of file..." to the constructor of class File. The method getName() returns the name
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
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
Finding out the super class name of the class
Finding out the super class name of the class   ... name by using the getSuperclass() method. The given example demonstrates the use...;. Populate it with the Checkbox objects. Now retrieve the Superclass name
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
Why <servlet-name> use in web.xml - JSP-Servlet
Why <servlet-name> use in web.xml  WHY DO WE USE THE <SERVLET-NAME>TAG IN WEB.XML APPLCATION   WHY DO WE USE THE <SERVLET-NAME>TAG IN WEB.XML APPLCATION AND HOW A simple program of using <servlet
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
Programming - Transform Name - Answer
Java: Programming - Transform Name - Answer Solution to: Write a program to redisplay a name, possibly transformed. This Java program will reformat a user's name from "First Last" to "Last, First". There are two cases
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
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.
Manipulating attributes
: Following code will remove 'blue' css class from all even... of attributes , i.e. CSS Class attribute General... CSS class attribute using following methods : .addClass() You can
Find Your Host Name
Find Your Host Name       Here we are going to explore a method to retrieve the host name of the local system in a very simple example. Here we are just call
Changing the Name of Column in a JTable
_name): This is the method that sets the object (column name) to use... Changing the Name of Column in a JTable       In this section, you will learn how to change
need solution to get file name from path which should give by user
need solution to get file name from path which should give by user  how do i write a program in java that i should get file path from arguments.currently this code creates the file at d:\ but i need to get this file name
personal name aliases
personal name aliases  enter the name search result in internet connection using java code   Please visit the following links: http...-Servlet/19987-search-functionality-using-jsp-from-database.html
Get Month Name Example
in understanding a how to get a 'Get Month Name Example'.For this we have a class...: Month name: October Download code... Get Month Name Example     
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
How to find a servlet object by name?
How to find a servlet object by name?  How can we locate a servlet object in the code by it's object name?   A. In web.xml you map servlet... the reference to another Servlet that Servlet's methods can be called
Shorting Table View By Column Name
Shorting Table View By Column Name This tutorial explains how to shorting table view by column name from the database in JSP and Servlet. This example... shorting  table view by column name. The code of "userdetails.jsp
Get Property by Name
by Name       In this Tutorial we want to describe you a code that helps you in understanding to get Property by Name. For this we have a class name "Get Property
Constructing a File Name path
Constructing a File Name path       This Java programming tutorial will teach you how you can construct a file name path. By using the constructing filename path
SQL Alter Table Name
SQL Alter Table Name       SQL Alter Table Name is used to change or modify  name of the existing table. To understand how to change the name of created table in SQL
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
Static/Class methods
methods, the class name should be specified. Eg, // Called from outside... Java NotesStatic/Class methods There are two types of methods. Instance.... Called from within the same class Just write the static method name. Eg
Programming - Transform Name
Java: Programming - Transform Name Write a program to redisplay a name, possibly transformed This Java program will reformat a user's name... methods, transform this string into the last name, comma, first name format. Some
Changing column name
the name of the field, but as a programmer we should be aware how we can change... the column name: mysql> select * from... Changing column name      
To retrieve the IP address from Host Name, vice-versac
To retrieve the IP address from Host Name, vice-versa... to explain the method to find out the IP address from host name and to vice verse. Here... the host name of that Host. Apart from all of this we put the condition for wrong

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.