Package py4j

Class NetworkUtil


  • public class NetworkUtil
    extends java.lang.Object

    Utility class used to perform network operations.

    Author:
    Barthelemy Dagenais
    • Constructor Summary

      Constructors 
      Constructor Description
      NetworkUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void quietlyClose​(java.io.Closeable closeable)  
      static void quietlyClose​(java.net.ServerSocket closeable)  
      static void quietlyClose​(java.net.Socket closeable)  
      static void quietlySetLinger​(java.net.Socket socket)
      Will send a RST packet on close, which should make both remote write and read operations fail.
      static java.lang.String safeReadLine​(java.io.BufferedReader reader)  
      static java.lang.String safeReadLine​(java.io.BufferedReader reader, boolean addSpace)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NetworkUtil

        public NetworkUtil()
    • Method Detail

      • safeReadLine

        public static java.lang.String safeReadLine​(java.io.BufferedReader reader,
                                                    boolean addSpace)
                                             throws java.io.IOException
        Parameters:
        reader -
        addSpace -
        Returns:
        A non-null String with an optional space if it is empty.
        Throws:
        java.io.IOException
      • safeReadLine

        public static java.lang.String safeReadLine​(java.io.BufferedReader reader)
                                             throws java.io.IOException
        Parameters:
        reader -
        Returns:
        A String of at least one character (space if null or empty).
        Throws:
        java.io.IOException
      • quietlyClose

        public static void quietlyClose​(java.io.Closeable closeable)
      • quietlyClose

        public static void quietlyClose​(java.net.ServerSocket closeable)
      • quietlyClose

        public static void quietlyClose​(java.net.Socket closeable)
      • quietlySetLinger

        public static void quietlySetLinger​(java.net.Socket socket)

        Will send a RST packet on close, which should make both remote write and read operations fail.

        Parameters:
        socket -