]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/util/IOUtils.java
Use console charset for reading/writing to stdin/out
[signal-cli] / src / main / java / org / asamk / signal / util / IOUtils.java
index b772887b0af48687c39c49ea6115ef3d1d840c55..9f220946cd09dcaa3b68c57e095adfc1a727e843 100644 (file)
@@ -39,6 +39,11 @@ public class IOUtils {
     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];
@@ -136,7 +141,7 @@ public class IOUtils {
             logger.info("Listening on socket: " + address);
             postBind(address);
         } catch (IOException e) {
-            throw new IOErrorException("Failed to bind socket: " + e.getMessage(), e);
+            throw new IOErrorException("Failed to bind socket " + address + ": " + e.getMessage(), e);
         }
         return serverChannel;
     }