안드로이드 개발 질문/답변
(글 수 45,052)
지금 제가 웹서버에 zip 파일 2M 가 정도 되는걸
앱 내부에서 다운로드 받는데
40초가 넘게 걸리네요
근데 브라우저에서 url 로 입력 해서 다운 받으니
5초도 안걸리는데
혹시 다운받는 방법중
String src = "서버 파일 이름";
String des = "저장할 경로";
InputStream in = null;
OutputStream out = null;
OutputStream out = null;
try{
in = new BufferedInputStream(new URL("src).openStream());
out = new BufferedOutputStream(new FileOutputStream(des));
in = new BufferedInputStream(new URL("src).openStream());
out = new BufferedOutputStream(new FileOutputStream(des));
int read;
while(true)
{
read = in.read();
if(read == -1) break;
out.write(read);
}
in.close();
out.close();
} catch (FileNotFoundException e) {
System.out.println("catch -> FileNotFoundException");
} catch (IOException e) {
System.out.println("catch -> IOException");
} finally {
if (in != null) try {in.close();System.out.println("in.close()");} catch (IOException e) {System.out.println("in.finally -> IOException");}
if (out != null)try {out.close();System.out.println("out.close()");} catch (IOException e) {System.out.println("out.finally -> IOException");}
}
while(true)
{
read = in.read();
if(read == -1) break;
out.write(read);
}
in.close();
out.close();
} catch (FileNotFoundException e) {
System.out.println("catch -> FileNotFoundException");
} catch (IOException e) {
System.out.println("catch -> IOException");
} finally {
if (in != null) try {in.close();System.out.println("in.close()");} catch (IOException e) {System.out.println("in.finally -> IOException");}
if (out != null)try {out.close();System.out.println("out.close()");} catch (IOException e) {System.out.println("out.finally -> IOException");}
}
이방법 보다 빠른 방법 아시는분 없을까요
읽어 주셔서 감사 합니다
더 빠른지는 모르겠네요. 근데 2메가가 40초라니.. ㅎㄷㄷ;;