Java School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a Java Expert!

Join 300,449 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,564 people online right now. Registration is fast and FREE... Join Now!




List all Class/Interface names in a file

 

List all Class/Interface names in a file

chetanpatil1984

3 Jul, 2009 - 05:56 AM
Post #1

New D.I.C Head
*

Joined: 1 Jan, 2009
Posts: 11



Thanked: 1 times
My Contributions
Hello there,

I am working on this project in which I need get all the Class(including abstract)/Interface names in a file. I tried reflection api but found none. Does anyone know the solution to this problem? I would be very thankful.

Eg: filename - Main.java
-----------------------------
CODE

public class Main{
public static void main(String[] args){}
}

class Class1{}

abstract class Class2{}

interface Interface1{}


I need a program which lists:
Main
Class1
Class2
Interface1

~cheers

User is offlineProfile CardPM
+Quote Post


NickDMax

RE: List All Class/Interface Names In A File

3 Jul, 2009 - 08:29 AM
Post #2

Can grep dead trees!
Group Icon

Joined: 18 Feb, 2007
Posts: 5,216



Thanked: 285 times
Dream Kudos: 1175
Expert In: Java/C++

My Contributions
Note that a java file can only contain 1 top level class or interface etc. and that name of that class/interface must match the name of the file.

So the above example should never happen in valid java.

That being said, are you talking about parsing a .java file, or a .class file, or a .jar file?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 01:48AM

Live Java Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month