Possible bugs with Java file system and non latin characters in file names

Martijn Verburg martijnverburg at gmail.com
Sun Oct 30 04:56:59 PDT 2011

Hi all,

I ran across some legacy I/O code that was causing some issues for a client.

I tried to see if this was already reported in the bugs database, but
I got a NPE from the Glassfish server trying to log in (the irony ;p),
so I thought l should report it here.  Under Java 6u29 and Java 7u1
the following sample code (which simply creates a FileReader and
prints out each file in a directory) behaves oddly when faced with a
file in the directory of the name Bérletmozgás-201110.txt.


import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;

public class NonLatinFilenameBugExample
    private static final String DIR = "/temp/";
    //on Windows: private static final String inbox = "c:/temp/";

    // Could pass in the path, but hard coded it for SSCE
    public static void main(String[] args)
        File dir = new File(DIR);
        File[] files = dir.listFiles();
        for (int i = 0; i < files.length; i++)
                new FileReader(files[i].getAbsolutePath());
            catch (FileNotFoundException e)
                // Dump the stack trace as proof

* It works fine under Windows listing the file
* It produces a FileNotFoundException under Linux and Mac OS X Lion
when the new FileReader(files[i].getAbsolutePath()); call is made
* Files of any type/extension/name are not discovered by the
dir.listFiles(); call under cygwin

Does this sound familiar to anyone at all?


More information about the nio-dev mailing list