This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes file Path representation in different OS?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "file Path representation in different OS??" Watch "file Path representation in different OS??" New topic
Author

file Path representation in different OS??

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
1) In Window OS file path are represented as “c:\a.txt”,but in other OS it might differ from Windows OS.
But in java if I use the below state how the “path of file” given in Windows OS and other OS also??

File f =new File(“path of the File:”)

2) in java class if I create file “a.txt” is valid in windows OS ,The same ”a.txt” is valid file in OS except windows ??.
If I have to create a class which should run in OS such as windows,Unix,Linux ,etc,then How I write my java class to create file?


3)Java has any standard representation to represent file path???

4) If I read path “c:/a”,then java consider “c:a” only,why this is?

Note I use Windows XP OS
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32708
    
    4
File class.
Colm Dickson
Ranch Hand

Joined: Apr 04, 2009
Posts: 84
Hello.

I'm not quite clear about what you are asking but I think you mean how to represent File object references on different operating systems. The documentation on the File class is very useful for this. There are a few static fields that return the separator for the OS you are using

e.g.
File.separatorChar will return '/' ojn Unix and '\\' on Windows

Is this what you mean?


Colm
Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
Read up on the File documentation, there are OS generic ways of representing paths.


SCJA
~Currently preparing for SCJP6
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: file Path representation in different OS??
 
Similar Threads
Create new file with spaces in file path
Java JDK Installation Problem - Need Help!
console output
Environment Variable!!
MAC OS X path