Filename Case Sensitivity: Another (Annoying?) Linux vs. Windows Difference

| No TrackBacks
Thumbnail image for java_logo.gifHere's another irritating Linux vs. Windows difference ...

On Windows, a file with a name of "README.txt" is the same as "readme.txt".  On Linux, these are two completely separate files.  This can make things tricky when developing Java code on Windows, and deploying on Linux.  If your code references a resource (a file of some kind) with mixed capitalization in the file name, you must remember that referencing that resource may work on Windows but probably not on Linux.

Let's say you have "myresource.txt" in a directory.  In Java ...

new File("MyReSoUrCe.tXt").exists() returns true on Windows.

new File("MyReSoUrCe.tXt").exists() returns false on Linux.

Granted, most people wouldn't put something ridiculous like "MyReSoUrCe.tXt" in their code.  A more likely example is "MyResource.txt".  But, you get the idea.  BTW, I have no significant personal preference with regards file name case sensitivity.  However, I suspect Microsoft intentionally left this file name case convention in place.  Therefore, Windows would be backwards compatible with older DOS applications that expect "README" to be the same file as "readme".

Bottom line, just use an all lower case naming convention for any resources referenced by your code; regardless of what platform you are developing/deploying on.  Doing so will save you many hassles in the long run.

Did You Find this Helpful?

Did you find this post helpful, or at least, interesting?

  

Send Mark a Direct Message

If you'd like to send me a direct message, please do so below. However, I do not publicly post comments or messages submitted directly to me. So, if you're going to try to SPAM me, or my blog, you're pretty much wasting your time.

400 characters remaining

Error

About Mark

A Silicon Valley native, Mark Kolich is a full-time Software Engineer, a casual entrepreneur, and a consultant for hire. A web technologies expert, his current focus is on building powerful and robust cloud-driven web-applications using Java, PHP, Perl, AJAX, DHTML, CSS, and JavaScript. His favorite programming languages are PHP, Java and JavaScript. He uses Linux, enjoys biking to work, loves building great software, and always writes elegant, readable, and maintainable code.

No TrackBacks

No trackbacks attached to this entry.

Twitter (@markkolich)

Translate

About this Entry

This page contains a single entry by Mark Kolich published on March 4, 2009 1:00 PM.

Using the Twitter API, Cache Your 'Tweets' in PHP (TwitterCacher) was the previous entry in this blog.

HOWTO: Make Your Own Tiny URL Alias Service (TinyURL, Bit.ly, Twurl.cc, etc.) With Apache RewriteMap is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.