• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing a folder in Current Directory  RSS feed

 
kirba devi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Having a source file and Images folder(containing images like .jpg,.png) in drive C:
ie for eg: C:\\TestImages.java and c:\\Images.

I want to access the resource(Images folder) using TestImages.java.

How can i do that?
Also i dont want to give absolute path

So please provide some example using relative path....


Regards
Kirba.
 
prakash chandra
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the .java file and images folder is inside the same folder then no need to give any path. Just

File file = new File("images\\xyz.jpg");

will automatically takes relative.
 
Bill Cruise
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure the .class file is in the same directory as your images directory. Most IDEs don't put your class files in the same place as your source code.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!