나는 이것이이 더 신속하고 더러운 솔루션처럼 들리는이 같은 어떤 것을 구현하는 가장 좋은 방법이라고 생각 해달라고하지만 여기
어쨌든 수는 HTTP 다운로드에 대한 예제 클래스입니다 그것은 파일 "yes.maint"또는 다른 파일 중 일부는 HTTP를 통해 액세스 할 수 있습니다, 당신은 HTTPResponse를 얻기 위해 실행 HTTPClient를 사용하여 부를 수있는 가정 트릭
http download java get
//------------------------------------------------------------//
// JavaGetUrl.java: //
//------------------------------------------------------------//
// A Java program that demonstrates a procedure that can be //
// used to download the contents of a specified URL. //
//------------------------------------------------------------//
// Code created by Developer's Daily //
// http://www.DevDaily.com //
//------------------------------------------------------------//
import java.io.*;
import java.net.*;
public class JavaGetUrl {
public static void main (String[] args) {
//-----------------------------------------------------//
// Step 1: Start creating a few objects we'll need.
//-----------------------------------------------------//
URL u;
InputStream is = null;
DataInputStream dis;
String s;
try {
//------------------------------------------------------------//
// Step 2: Create the URL. //
//------------------------------------------------------------//
// Note: Put your real URL here, or better yet, read it as a //
// command-line arg, or read it from a file. //
//------------------------------------------------------------//
u = new URL("http://200.210.220.1:8080/index.html");
//----------------------------------------------//
// Step 3: Open an input stream from the url. //
//----------------------------------------------//
is = u.openStream(); // throws an IOException
//-------------------------------------------------------------//
// Step 4: //
//-------------------------------------------------------------//
// Convert the InputStream to a buffered DataInputStream. //
// Buffering the stream makes the reading faster; the //
// readLine() method of the DataInputStream makes the reading //
// easier. //
//-------------------------------------------------------------//
dis = new DataInputStream(new BufferedInputStream(is));
//------------------------------------------------------------//
// Step 5: //
//------------------------------------------------------------//
// Now just read each record of the input stream, and print //
// it out. Note that it's assumed that this problem is run //
// from a command-line, not from an application or applet. //
//------------------------------------------------------------//
while ((s = dis.readLine()) != null) {
System.out.println(s);
}
} catch (MalformedURLException mue) {
System.out.println("Ouch - a MalformedURLException happened.");
mue.printStackTrace();
System.exit(1);
} catch (IOException ioe) {
System.out.println("Oops- an IOException happened.");
ioe.printStackTrace();
System.exit(1);
} finally {
//---------------------------------//
// Step 6: Close the InputStream //
//---------------------------------//
try {
is.close();
} catch (IOException ioe) {
// just going to ignore this one
}
} // end of 'finally' clause
} // end of main
} // end of class definition
을로드해야하는 이미지를 확인하거나 http://stackoverflow.com/questions/4596447/java-check-if-file을 확인하십시오. -exists-on-remote-server-its-url을 사용합니다. – sherif