2012-02-28 2 views
0

서버 컴퓨터에서 exe 파일을 다운로드 할 수 없습니다.원격 위치에서 exe 파일을 다운로드 할 수 없습니다.

I.E. 내 위치 컴퓨터에서 exe 파일을 다운로드하여 디스크에 저장할 수 있지만 다른 서버에서는 저장할 수는 없지만 서버 컴퓨터에서 액세스하려고 할 때 다운로드하지 않고 다음과 같은 오류가 표시 될 수 있습니다.

나는 FileNotFoundException이를 해결하려면 어떻게

fileInputStream = new FileInputStream(new File("E:\\Sunnywellshare\\perl\\filezilla.exe")) 
//this code is working fine 

fileInputStream = new FileInputStream(new File("http://10.127.10.10/test/filezilla.exe")); 
//this code is from remote location.and throwing error 

: 아래

java.io.FileNotFoundException: http:\10.128.10.60\home\test\filexilla.exe(The filename, directory name, or volume label syntax is incorrect) 

내 코드?

답변

0

FileInputStream을 사용하여 URL을 열 수 없습니다! URLConnection을 사용하고 그 중에서 InputStream을 얻을 수 있습니다. InputStream에서 모든 데이터를 복사하고 (아마도) 로컬 파일에 저장해야합니다.

-1
import java.net.*; 
import java.io.*; 

public class URLReader { 
    public static void main(String[] args) throws Exception { 
    URL oracle = new URL("http://www.oracle.com/"); 
    BufferedReader in = new BufferedReader(
     new InputStreamReader(
     oracle.openStream())); 

    String inputLine; 

    while ((inputLine = in.readLine()) != null) 
     System.out.println(inputLine); 

    in.close(); 
    } 
} 
+0

여기서'Reader' 클래스는 문자 데이터가 아닌 이진 파일 인'* .exe' 파일을 mangle합니다. 'URL'에서 직접'InputStream'을 사용해야합니다. –

+0

나는 당신의 대답을주기 전에 조금이라도 읽을 필요가 있다고 생각한다. http://docs.oracle.com/javase/tutorial/networking/urls/readingURL.html – Churk

+0

당신의 코드는 HTML 파일을 읽는 데 적합하다.)하지만'* .exe' 파일을 다운로드하는 것은 아닙니다. 이것은 질문에 관한 것입니다. '* .exe'와 같은 이진 데이터에이 코드를 사용하면 파일이 손상됩니다. –

관련 문제