• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
Bartenders:
  • Himai Minh
  • Carey Brown
  • Frits Walraven

file Path representation in different OS??

 
Ranch Hand
Posts: 592
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 73334
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
File class.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read up on the File documentation, there are OS generic ways of representing paths.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic