This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get package structure in java  RSS feed

 
Bharat Makwana
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have one file under some package say, com/xxx/ccc/Test.txt. now i want under which package is this file ? Can anyone tell me what can i do to find that package structure in java. I know i can get package structue of .class file using CLASSNAME.class.getPackage(). But i want to get package structure of any file

Thanks & Regards
 
Jan van Mansum
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Test.txt is not a Java class or interface so it doesn't have java.lang.Class
object that represents it.

What is the context of your question? Why do you need to read a text file that you don't know the location of?
 
Srikanth Basa
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How you are representing the file in yor program ? If you are using the java.io.File object then try the method to get the the file Path in java.io.File class. Is that what you were looking for ?

It is a file in some folder structure so why you call that as package.
[ October 30, 2007: Message edited by: Srikanth Basavaraju ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!