안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요?
지금 파일 다운로드 하는 앱을 만들고 있는데
파라미터로 서버 url이랑, 파일 저장위치 보내주는데
서버와 통신하다가 아래 빨간 글씨 부분에서 자꾸 실패하네요
원인이 뭘까요...
public boolean doDownload(String sUrl, String tmpfilepath) {
Log.e("jiran", "httputil doDownload()");
HttpGet method = new HttpGet(sUrl);
DefaultHttpClient client = new DefaultHttpClient();
method.setHeader("Connection", "Keep-Alive");
client.setCookieStore(_cookieStore);
client.getParams().setParameter("http.socket.timeout", new Integer(3000));
try {
HttpResponse response = client.execute(method);
int status = response.getStatusLine().getStatusCode();
if (status == HttpStatus.SC_OK) {
File file = new File(tmpfilepath);
InputStream is = response.getEntity().getContent();
BufferedInputStream in = new BufferedInputStream(is, 512000);
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file, false), 512000);
byte buf[] = new byte[512000];
int readsize = -1;
while((readsize = in.read(buf)) != -1)
{
out.write(buf, 0, readsize);
//log(Integer.toString(readsize));
}
out.flush();
out.close();
in.close();
}
else if (status == HttpStatus.SC_NOT_FOUND)
throw new Exception("");
else
throw new Exception("");
} catch (Exception e) {
return false;
} finally {
client.getConnectionManager().shutdown();
}
return true;
}




퍼미션은 확인 하셨죠???