【发布时间】:2011-11-04 03:58:23
【问题描述】:
我正在尝试在我公司的网站中搜索特定字符串,以检查该网站是否存在。 你能告诉我怎么做吗?
到目前为止,这是我的代码:
public static void main(String[] args) throws Exception {
try {
URL oracle = new URL("http://10.200.10.199:80");
BufferedReader in = new BufferedReader(new InputStreamReader(
oracle.openStream()));
inputLine = in.readLine();
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
}
in.close();
} catch (IOException e) {
// TODO: handle exception
System.out.println("Page was not found - might not be running");
}
【问题讨论】:
-
当你运行代码时会发生什么?你看到任何输出了吗?如果您遇到异常,那么我会将其打印出来或至少打印出消息。
-
您重新发明轮子有什么特别的原因吗?为什么不运行 Icinga 之类的东西:icinga.org?
-
程序正在运行并打印来自网页的数据。现在我想检查接收到的数据中是否存在字符串。 ddrace - 我是自愿做这个项目的,我想通过这个来学习。