• 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
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

file separators

 
Ranch Hand
Posts: 309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am aware of using File.separator to specify system independent paths. But I was wondering, if that is really required. For example I read files in my windows machine using "/" as separator and it works. I use only relative path names. These paths should also work on Unix machines as "/" is the path separator there anyways. So do I really need to change all those "/" to File.separator in my code. In my opinion, unless you are using absolute path names in your code,you should not face any problem in using "/" thoughout your code.Right? or Am i missing something here??? BTW I use JDK1.4
Shankar.
 
Bartender
Posts: 9625
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The goal of Java is to be platform independent, so to that goal they've made platform-specific information available via the system properties. Though you've tested two platforms with "/" it doesn't mean it will work on ALL platforms. I can't think of one that doesn't recognize the "/" file seperator. I guess it boils down to the requirements of your program. Do you intend to deploy on Windows and Unix? Go ahead and use "/". Do you want to be VERY platform-independent? Use file.seperator.
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the old days, Macs used ":" as a path separator, and "/" would not be recognized if you used it when calling the Macintosh Toolbox APIs. I don't recall if early Mac JDKs (who else remembers the truly dreadful Macintosh port of JDK 1.0.2?) would let you use "/", but I doubt it -- it's Windows itself that accepts either "\" or "/" (you can use "/" when calling Win32 functions from any language.)
Now, with Mac OS X, I assume "/" is OK, but again, I'm not sure.
 
Seriously Rick? Seriously? You might as well just read this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic