Note that there are some explanatory texts on larger screens.

plurals
  1. POMac OS X, Java 7: createNewFile filename encoding
    primarykey
    data
    text
    <p>I'm trying to update a application, running mainly on Mac OSX, from Java6 to Java7. It occurs that files beeing creating with some special characters in the filename e.g. "föhn.txt" are beeing created as "f?hn.txt" with Java7.</p> <p>If you run this sort example on a Mac</p> <pre><code>File file = new File("föhn.txt"); file.createNewFile(); </code></pre> <ul> <li>with Java6: föhn.txt</li> <li>with Java7: f?hn.txt</li> </ul> <p>I know there're simular threads for this topic:</p> <ul> <li><a href="https://stackoverflow.com/questions/10106161/encoding-of-file-names-in-java">Encoding of file names in Java</a></li> <li><a href="https://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding">Setting the default Java character encoding?</a></li> </ul> <p>and I've tryed to set JVM argument: <code>-Dfile.encoding=UTF8</code> but this has no effect to the filename. Compiler and source are set to utf-8. I've no idea why this is not working with Java7 on OS X.</p> <p>Update: I've tried the example within eclipse and Netbeans and the final application is bundled with the jdk (appbundler).</p> <p>Mac OS X uses a decomposed UTF-8 format: <a href="https://stackoverflow.com/questions/3610013/file-listfiles-mangles-unicode-names-with-jdk-6-unicode-normalization-issues">File.listFiles() mangles unicode names with JDK 6 (Unicode Normalization issues)</a></p> <p>And a blog about this topic: <a href="http://shlrm.org/blog/2012/10/04/osx-java-utf-8-oh-my/" rel="nofollow noreferrer">http://shlrm.org/blog/2012/10/04/osx-java-utf-8-oh-my/</a></p> <p>This helps reading filenames but I've not found a solution for creating new files with the correct encoded filename.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload