Topic
  • No replies
benro02
benro02
2 Posts

Pinned topic java.nio.file doesn't work properly in z/OS with file.encoding=ISO8859-1

‏2012-05-18T15:26:20Z |
We're using java.nio.file classes to get information about a mounted ZFS file system. When this code is executed in a JBOSS server environment, which requires file.encoding=ISO8859-1, we get a java.nio.file.NoSuchFileException when we try to use the getFileStore method. The problem does not occur when I run this as a standalone program with the default file.encoding. Is this a bug, or is there something extra I need to do to compensate for the file.encoding setting with this class?

niotest.java:
import java.nio.file.*;
import java.io.IOException;

public class niotest
{
public static void main(String[] args)
{
try {
String pathstring = new String("/bin/ls");
Path mypath = FileSystems.getDefault().getPath(pathstring);
System.out.println("mypath is '"mypath.toString()"'");
System.out.println("file.encoding is '"System.getProperty("file.encoding")"'");
FileStore myfs = Files.getFileStore(mypath);
System.out.println("Current file system, name: "+myfs.name());
System.out.println("Current file system, type: "+myfs.type());
System.out.println("Current file system, isReadOnly: "+myfs.isReadOnly());
System.out.println("Current file system, total space: "myfs.getTotalSpace()/1024"KB");
System.out.println("Current file system, unalloc space: "myfs.getUnallocatedSpace()/1024"KB");
System.out.println("Current file system, usable space: "myfs.getUsableSpace()/1024"KB");
} catch (IOException e) {
System.out.println("exception encountered getting file system info - "+e.getMessage());
e.printStackTrace();
}
}
}

run with file.encoding=ISO8859-1:

> java -Dfile.encoding=ISO8859-1 niotest
mypath is '/bin/ls'
file.encoding is 'ISO8859-1'
exception encountered getting file system info - /bin/ls
java.nio.file.NoSuchFileException: /bin/ls
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:98)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:114)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:119)
at sun.nio.fs.UnixFileStore.devFor(UnixFileStore.java:69)
at sun.nio.fs.UnixFileStore.<init>(UnixFileStore.java:76)
at sun.nio.fs.ZosFileStore.<init>(ZosFileStore.java:20)
at sun.nio.fs.ZosFileSystemProvider.getFileStore(ZosFileSystemProvider.java:27)
at sun.nio.fs.ZosFileSystemProvider.getFileStore(ZosFileSystemProvider.java:19)
at sun.nio.fs.UnixFileSystemProvider.getFileStore(UnixFileSystemProvider.java:379)
at java.nio.file.Files.getFileStore(Files.java:1416)
at niotest.main(niotest.java:13)

Run with default file.encoding:

java niotest
mypath is '/bin/ls'
file.encoding is 'IBM-1047'
Current file system, name: OMVS.PROD113D.ROOT
Current file system, type: ZFS
Current file system, isReadOnly: false
Current file system, total space: 2334240KB
Current file system, unalloc space: 25789KB
Current file system, usable space: 25789KB