aspose file tools*
The moose likes Beginning Java and the fly likes File loading and paths when running in an IDE, and outside an IDE. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "File loading and paths when running in an IDE, and outside an IDE." Watch "File loading and paths when running in an IDE, and outside an IDE." New topic
Author

File loading and paths when running in an IDE, and outside an IDE.

Nick Wiggill
Greenhorn

Joined: Jun 12, 2010
Posts: 4
Hello all. My first post here although I first came upon your friendly forums many moons ago.

I'm an experienced developer, but not with Java. And there is something that has really been eating my brain of late that I feel I need to come to terms with. And that is file paths in Java.

I have some questions.


1) Reading and writing files: What is my best option, Files, Streams, <name your own method here>, and why? So far I'm leaning towards streams because they seem more flexible in a sense, but maybe that also makes life a little more difficult.

2) I want to be sure that my application will run happily both in Eclipse, and outside Eclipse as a standalone jar, without file pathing issues. What process should I follow to ensure this is the case?

3) I have also considered deploying as a web-based applet or possibly JNLP, and I'd be really interested to also hear what these entail in terms of getting paths correct; and if there is one good way of designing my applications pathing and loading to deal with any of the above scenarios, so future apps can be more flexible.


I guess that's the gist of it, I might have more Q's as they come to me.

Looking forward to your replies.


www.handcraftedgames.net
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Nick Wiggill wrote:2) I want to be sure that my application will run happily both in Eclipse, and outside Eclipse as a standalone jar, without file pathing issues. What process should I follow to ensure this is the case?

If you don't need to write to these files you should use resources; check out Class.getResource and Class.getResouceAsStream, and their cousins in ClassLoader.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39380
    
  28
And welcome to JavaRanch
Nick Wiggill
Greenhorn

Joined: Jun 12, 2010
Posts: 4
Thank you, both
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File loading and paths when running in an IDE, and outside an IDE.