JAVA.GET_OWNER get owner of file

if stdlib.exists() was not adequate here, as on some CI systems, say Windows with Matlab R2025a, despite the same setup on a laptop working. stdlib.exists() was true, the Java function threw java.nio.file.NoSuchFileException.

this try-catch is faster and more robust

function n = get_owner(file)

% https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/Files.html#getOwner(java.nio.file.Path,java.nio.file.LinkOption...)
% https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/LinkOption.html

n = "";
if stdlib.strempty(file)
  return
end

% Java 1.8 benefits from absolute.
% We only saw this issue with R2025a on windows-2025 GA runner image.
opt = java.nio.file.LinkOption.values();

try
  n = string(java.nio.file.Files.getOwner(javaAbsolutePath(file), opt));
catch e
  javaException(e)
end

end