private IOUtils() {
}
+ public static Charset getConsoleCharset() {
+ final var console = System.console();
+ return console == null ? Charset.defaultCharset() : console.charset();
+ }
+
public static String readAll(InputStream in, Charset charset) throws IOException {
var output = new StringWriter();
var buffer = new byte[4096];
return socketAddress;
}
- public static UnixDomainPrincipal getUnixDomainPrincipal(final SocketChannel channel) throws IOException {
+ public static String getUnixDomainPrincipal(final SocketChannel channel) throws IOException {
UnixDomainPrincipal principal = null;
try {
principal = channel.getOption(ExtendedSocketOptions.SO_PEERCRED);
- } catch (UnsupportedOperationException ignored) {
+ } catch (UnsupportedOperationException | NoClassDefFoundError ignored) {
}
- return principal;
+ return principal == null ? null : principal.toString();
}
public static ServerSocketChannel bindSocket(final SocketAddress address) throws IOErrorException {