java - Cross-platform file path building and representation -


i in refactoring stage project working on , make improvements how build , represent file system paths. things should take consideration when representing relative paths in java code ensure compatibility on ubuntu, osx, , windows 7.

currently instance of file referencing "myproject/foo/bar.f" have code along lines of:

file bar = new file(projectdirectory + "/" + fooresourcedirectory + "/" + barname);

this seems wrong several reasons, of best practices?

perhaps use constructors provided sort of thing:

new file(parent, child) 

you have "nest" them, it's trivial handle (e.g. make function path built taking string....)

see file constructors.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -