java.net.URL url = null;
java.net.URLConnection urlCon;
try {
url = new java.net.URL("http://服务器IP:端口/upload/ABC.doc");
urlCon = url.openConnection();
String message = urlCon.getHeaderField(0);
System.out.println(message);//文件存在打印‘HTTP/1.1 200 OK’ 文件不存在打印 ‘HTTP/1.1 404 Not Found’
} catch (java.net.MalformedURLException e0) {
} catch (java.io.IOException ie3) {
}
时间: 2024-10-06 19:44:09