Special characters in File objects on macintosh

J

jonfogh

Hi There

I have a problem with files containing some characters.

The file /Users/Test/æøåÆØÅ is handled by the io.File object, but
when calling getAbsolutpath on the object i get:
/Users/Test/æøa?ÆØA?

This means å becomes a? and Å becomes A?

Do somebody know why this happens and how to solve the problem?

Jon
 
S

Steve W. Jackson

jonfogh said:
Hi There

I have a problem with files containing some characters.

The file /Users/Test/æøåÆØÅ is handled by the io.File object, but
when calling getAbsolutpath on the object i get:
/Users/Test/æøa?ÆØA?

This means å becomes a? and Å becomes A?

Do somebody know why this happens and how to solve the problem?

Jon

Whether or not it's a "problem" depends in large part on how you expect
to use the returned absolute path.

Longtime Mac developers know that absolute paths are generally not
useful for numerous reasons. I haven't done much work with File objects
there in Java, but I know that some non-Java environments display the
file's name differently than they would when including it in an absolute
path string for encoding reasons.

So the question I would ask is whether the getName method on the File
object displays this same changed string as seen in the absolute path.
If not, and if you truly need the absolute path, you might instead
consider traversing from the file, via its getParent method, up channel
to the root volume name. You might also want to keep in mind that,
prior to Mac OS X 10.4, the boot volume was not available via /Volumes,
whereas in 10.4 there's automatically a symbolic link created under
/Volumes with the name of the boot volume. That means, for instance,
that my PowerBook's "Macintosh HD" root directory can now be correctly
referred to as "/" or as "/Volumes/Macintosh HD/".

= Steve =
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,138
Latest member
NevilleLam
Top