net.roboconf.core.utils.Utils.findUrlAndPort()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中net.roboconf.core.utils.Utils.findUrlAndPort()方法的一些代码示例,展示了Utils.findUrlAndPort()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.findUrlAndPort()方法的具体详情如下:
包路径:net.roboconf.core.utils.Utils
类名称:Utils
方法名:findUrlAndPort

Utils.findUrlAndPort介绍

[英]Parses a raw URL and extracts the host and port.
[中]解析原始URL并提取主机和端口。

代码示例

代码示例来源:origin: net.roboconf/roboconf-messaging-rabbitmq

Map.Entry<String,Integer> entry = Utils.findUrlAndPort( messageServerIp );
factory.setHost( entry.getKey());
if( entry.getValue() > 0 )

代码示例来源:origin: roboconf/roboconf-platform

@Test
public void testFindUrlAndPort() throws Exception {
  Map.Entry<String,Integer> entry = Utils.findUrlAndPort( "http://localhost" );
  Assert.assertEquals( "http://localhost", entry.getKey());
  Assert.assertEquals( -1, entry.getValue().intValue());
  entry = Utils.findUrlAndPort( "http://localhost:9989" );
  Assert.assertEquals( "http://localhost", entry.getKey());
  Assert.assertEquals( 9989, entry.getValue().intValue());
  entry = Utils.findUrlAndPort( "http://roboconf.net/some/arbitrary/path" );
  Assert.assertEquals( "http://roboconf.net/some/arbitrary/path", entry.getKey());
  Assert.assertEquals( -1, entry.getValue().intValue());
  entry = Utils.findUrlAndPort( "http://roboconf.net:2727/some/arbitrary/path" );
  Assert.assertEquals( "http://roboconf.net/some/arbitrary/path", entry.getKey());
  Assert.assertEquals( 2727, entry.getValue().intValue());
  File f = new File( System.getProperty( "java.io.tmpdir" ));
  entry = Utils.findUrlAndPort( f.toURI().toString());
  Assert.assertEquals( f.toURI(), new URI( entry.getKey()));
  Assert.assertEquals( -1, entry.getValue().intValue());
  entry = Utils.findUrlAndPort( "ftp://some.host.com:4811/path" );
  Assert.assertEquals( "ftp://some.host.com/path", entry.getKey());
  Assert.assertEquals( 4811, entry.getValue().intValue());
}

相关文章

微信公众号

最新文章

更多