【发布时间】:2018-11-16 19:19:49
【问题描述】:
我需要的是一种回到顶部的方法是触发一个特殊事件,这是我在 C# 中的代码
public void SendRequest()
{
send:
{
var response = new RequestBuilder("https://google.com").
WithMethod(HttpMethod.GET).
Send();
if (response.Contains("Special Keyword"))
goto send;
// Continue..
}
}
此代码在 C# 中工作,它会重新发送请求,直到页面不包含“特殊关键字”
知道如何在 Java 中做同样的事情吗?
这是我尝试过的,但即使页面包含“特殊关键字”,它最终也会显示“完成”
public void SendRequest() {
send: {
String response = new RequestBuilder().
to("https://google.com").
buildAndSend().
toString();
if(response.contains("Special Keyword"))
break send;
// Continue..
System.out.println("Done");
}
}
【问题讨论】:
-
goto有合法用途。这不是一个。