• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get package structure in java

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic