• No replies
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?
import java.nio.file.*;

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: ";
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());

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(
at sun.nio.fs.UnixException.rethrowAsIOException(
at sun.nio.fs.UnixException.rethrowAsIOException(
at sun.nio.fs.UnixFileStore.devFor(
at sun.nio.fs.UnixFileStore.<init>(
at sun.nio.fs.ZosFileStore.<init>(
at sun.nio.fs.ZosFileSystemProvider.getFileStore(
at sun.nio.fs.ZosFileSystemProvider.getFileStore(
at sun.nio.fs.UnixFileSystemProvider.getFileStore(
at java.nio.file.Files.getFileStore(
at niotest.main(

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