posted by Full-stack Developer 2011. 10. 17. 16:51
void downloadData(String addr){
StringBuilder html = new StringBuilder();
try{
URL url = new URL(addr);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
if(conn != null){
conn.setConnectTimeout(10000);
conn.setUseCaches(false);
if(conn.getResponseCode() == HttpURLConnection.HTTP_OK){
File book=new File("/sdcard/filedir", "filename.dat");
       FileOutputStream fileOutput = new FileOutputStream(book);
       InputStream inputStream = conn.getInputStream();
       int downloadedSize = 0;
       byte[] buffer = new byte[1024];
       int bufferLength = 0; 
       while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
               fileOutput.write(buffer, 0, bufferLength);
               downloadedSize += bufferLength;
       }
       fileOutput.close();
}
}
}catch(Exception ex){;}
}

안녕하세요 ^^
잠시 설명을 해볼까 합니다ㅎ

파일다운받을때 http방식으로 다운받는 로직인데요.
addr에 파일 풀경로를 넣어주시고
노란색으로 표시된부분에 다운받을실 경로와 파일명을 기입해주시면
끗!

도움이 되셨길 빌어요 ^^
즐코딩! 낫빡침!