• Post Reply Bookmark Topic Watch Topic
  • New Topic

File Class

 
Joe Shamana
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi;
I'm trying to find out how I can get the File Object (directory) of a certain java class that I'm using.
e.g. if I have Class Foo in package com.super.app.util how can I create a file in the same directory as Foo. (From a client)
When I do File file = new File("test.txt"); the file gets created in my home directory.
Foo foo = new Foo();
File file = new File(<same dir as foo>, "test.txt");
thats my question in java ... =]
thanks in advance
 
Joe Shamana
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually same directory as Foo.class
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general there's no obvious way to do this unless you know a bit more about how your classes are arranged.
Imagine what would happen if you tried to call a method like this on a class in a "jar" file, or one loaded over the network !
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!