devxlogo

The java.io.File class and Microsoft file systems

The java.io.File class and Microsoft file systems

Question:
After about 4 hours of work, I’d come up with an application (alltext, runs from the command line) that asks for a starting directory,and recursively writes all of that directory’s file names (includingfiles in subdirectories) and the directories they reside in to acomma-delimited text file. It works beautifully, unless you use aroot directory to start in. In other words, you can pass it”c:windows”, but not “c:”. We want to index off the root of theCD-ROMs, so this is a problem.

Answer:
There is a bug in some Java implementations where C: is not a validfilename under Microsoft Windows95/NT, producing unpredictable errors.To reliably access the root directory, you currently have to append adot to the directory path. For example, use the Java String “C:\.”instead of “C:\”.

See also  How College Students Can Shape the Future of Tech Responsibility
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist