마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

웹서버에서 파일 다운로드 질문이요~

0 추천
URL url;
                int Read;
                try {
                    url= new URL(file_url);
                    HttpURLConnection conn= (HttpURLConnection)imageurl.openConnection();
                    conn.connect();
                    int len = conn.getContentLength();
                    byte[] raster = new byte[len];
                    InputStream is = conn.getInputStream();
                    FileOutputStream fos = openFileOutput(FileName, 0);

                    for (;;) {
                        Read = is.read(raster);
                        if (Read <= 0) {
                            break;
                        }
                        fos.write(raster,0, Read);
                    }

                    is.close();
                    fos.close();
                } catch (Exception e) {
                    return false;
                }
                return true;

구글링해서 해봤는데 아래처럼만 나오고 다운로드는 안되네요....

11-04 18:52:09.433 6452-6452/com.example.jhkim.test2 I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
11-04 18:52:09.433 6452-6452/com.example.jhkim.test2 I/System.out: (HTTPLog)-Static: isSBSettingEnabled false

로그 찍어보니까

conn.connect(); 부분에서 끝나는거 같은데 이유를 모르겠어요ㅠㅠ

url이 http://203.252.22.62/files/attach/binaries/147/572/639/d56bfb97ce09cf45dee802f413c33f60이렇게 되있는데 이게 문제가 될 수도 있나요??

 

 

 

뱅이 (620 포인트) 님이 2017년 11월 4일 질문

1개의 답변

+1 추천
 
채택된 답변

connect 에서 끊났다면,  서버로 접속 시도 했다가, 연결이 안되서 IOException 이 발생했을 겁니다.

폰 브라우져에서 http://203.252.22.62/files/attach/binaries/147/572/639/d56bfb97ce09cf45dee802f413c33f60 를 입력해서 연결되는지 부터 확인 해 보세요.

 

익명사용자 님이 2017년 11월 6일 답변
뱅이님이 2017년 11월 6일 채택됨
...