Unix paths as bytes

Alan Bateman Alan.Bateman at Sun.COM
Mon May 4 03:49:48 PDT 2009


Martin Buchholz wrote:
> :
>
> The Paths API seems to be parallel to the environment variable API
> in that it catches most of the places where file names would be
> corrupted by round-trip encoding/decoding, but it is easy to
> construct sample code where the abstraction is leaky,
> E.g. if you try to construct a file name from the concatenation of
> an existing file name and a suffix defined in Java code as a string.
> (Correct me if I'm wrong)
>   
Yes, that's right. The main problem we wanted to avoid was where you get 
a Path to a file from a directory iteration but you can't access the 
file because the byte representation isn't right after the round-trip.

Here's a good presentation on the issues (just wish something had come 
of it):
  
http://developers.sun.com/global/products_platforms/solaris/reference/presentations/IUC29-FileSystems.pdf

It would be easy to expose the bytes with something like 
toString(CharsetDecoder) and a corresponding 
FileSystem.getPath(String,CharsetEncoder) for import but I wouldn't 
expect it would be used by regular applications.

-Alan.



More information about the nio-dev mailing list