public static SocketAddress parseSocketAddress(String value) {
    if (value.startsWith(UNIX_DOMAIN_SOCKET_PREFIX)) {
      // Unix Domain Socket address.
      // Create the underlying file for the Unix Domain Socket.
      String filePath = value.substring(UNIX_DOMAIN_SOCKET_PREFIX.length());
      File file = new File(filePath);
      if (!file.isAbsolute()) {
        throw new IllegalArgumentException("File path must be absolute: " + filePath);
      }
      try {
        if (file.createNewFile()) {
          // If this application created the file, delete it when the application exits.
          file.deleteOnExit();
        }
      } catch (IOException ex) {
        throw new RuntimeException(ex);
      }
      // Create the SocketAddress referencing the file.
      return new DomainSocketAddress(file);
    } else {
      // Standard TCP/IP address.
      String[] parts = value.split(":", 2);
      if (parts.length < 2) {
        throw new IllegalArgumentException(
            "Address must be a unix:// path or be in the form host:port. Got: " + value);
      }
      String host = parts[0];
      int port = Integer.parseInt(parts[1]);
      return new InetSocketAddress(host, port);
    }
  }
public static SocketAddress parseSocketAddress ( String value ) { if ( value . startsWith ( UNIX_DOMAIN_SOCKET_PREFIX ) ) { String filePath = value . substring ( UNIX_DOMAIN_SOCKET_PREFIX . length ( ) ) ; File file = new File ( filePath ) ; if ( ! file . isAbsolute ( ) ) { throw new IllegalArgumentException ( "File path must be absolute: " + filePath ) ; } try { if ( file . createNewFile ( ) ) { file . deleteOnExit ( ) ; } } catch ( IOException ex ) { throw new RuntimeException ( ex ) ; } return new DomainSocketAddress ( file ) ; } else { String [ ] parts = value . split ( ":" , 2 ) ; if ( parts . length < 2 ) { throw new IllegalArgumentException ( "Address must be a unix:// path or be in the form host:port. Got: " + value ) ; } String host = parts [ 0 ] ; int port = Integer . parseInt ( parts [ 1 ] ) ; return new InetSocketAddress ( host , port ) ; } }
Parse a {@link SocketAddress} from the given string.