2017-12-11 2 views

답변

0

onItemClickListener 쓰기 코드는

int count; 
try { 
    URL url = new URL("YOUR_URL"); 
    URLConnection conection = url.openConnection(); 
    conection.connect(); 

    int lenghtOfFile = conection.getContentLength(); 

    InputStream input = new BufferedInputStream(url.openStream(), 8192); 
    OutputStream output = new FileOutputStream("DOWNLOAD_LOCATION"); 

    byte data[] = new byte[1024]; 
    long total = 0; 

    while ((count = input.read(data)) != -1) { 
     total += count; 
     output.write(data, 0, count); 
    } 

    output.flush(); 
    output.close(); 
    input.close(); 

} catch (Exception e) { 
    e.printStackTrace(); 
} 

참고 어떤 파일을 다운로드 : 당신은 AsyncTaskandroid.permission.INTERNET이 필요한이 코드를 작성해야합니다.

관련 문제