本文整理了Java中net.roboconf.core.utils.Utils.findUrlAndPort()
方法的一些代码示例,展示了Utils.findUrlAndPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.findUrlAndPort()
方法的具体详情如下:
包路径:net.roboconf.core.utils.Utils
类名称: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());
}
内容来源于网络,如有侵权,请联系作者删除!