How can I read Arabic characters in a filename with FileUtils.listFiles in Java?

316 Views Asked by At

This is a method that returns a String array with all my files name in a specific folder. It works perfectly but doesn't work when reading a file with Arabic characters in it's filename. Any help is appreciated.

String[] name = new String[10];
        String[] finalName = new String[10];
        int i=0;
        File file = new File("/Users/Rakuten/Desktop/Trial");       
        Collection<File> files = FileUtils.listFiles(file, null, true);  
        for(File file2 : files){
            name[i]=file2.getName();
            finalName[i]=name[i].replace(".ppt","");
            i++;

        }

        return finalName;
1

There are 1 best solutions below

0
On

I've fixed the problem by duplicating the file in question and changing it's name to Latin-alphabet. Trivial solution because I don't really need the file afterwards, I just need the name of the file written on a PowerPoint and linked to it. And I would have stored this name before I rename the file.