本文整理了Java中net.roboconf.core.utils.Utils.readUrlContent()
方法的一些代码示例,展示了Utils.readUrlContent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.readUrlContent()
方法的具体详情如下:
包路径:net.roboconf.core.utils.Utils
类名称:Utils
方法名:readUrlContent
[英]Reads the content of an URL (assumed to be text content).
[中]读取URL的内容(假定为文本内容)。
代码示例来源:origin: roboconf/roboconf-platform
/**
* Reads the content of an URL (assumed to be text content).
* @param url an URL
* @return a non-null string
* @throws IOException
* @throws URISyntaxException
*/
public static String readUrlContentQuietly( String url, Logger logger ) {
String result = "";
try {
result = readUrlContent( url );
} catch( Exception e ) {
logger.severe( "Content of URL " + url + " could not be read." );
logException( logger, e );
}
return result;
}
代码示例来源:origin: roboconf/roboconf-platform
@Test
public void testReadUrlContent() throws Exception {
File f = this.folder.newFile();
Utils.writeStringInto( "kikou", f );
String readContent = Utils.readUrlContent( f.toURI().toURL().toString());
Assert.assertEquals( "kikou", readContent );
Utils.deleteFilesRecursively( f );
Assert.assertFalse( f.exists());
Logger logger = Logger.getLogger( getClass().getName());
readContent = Utils.readUrlContentQuietly( f.toURI().toURL().toString(), logger );
Assert.assertEquals( "", readContent );
}
内容来源于网络,如有侵权,请联系作者删除!