-
웹에 존재하는 파일 Stream을 이용해서 다운로드 하기안드로이드/개발 팁 2011. 2. 18. 23:06
String src="http://192.168.1.106/football.3gp"; String des="sdcard/temp1357.3gp"; InputStream in = null; OutputStream out = null; try{ 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(); finish(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block System.out.println("aa"); } catch (IOException e) { // TODO Auto-generated catch block System.out.println("bb"); } finally { if (in != null) try { System.out.println("cc"); in.close(); } catch (IOException e) { System.out.println("dd"); // TODO Auto-generated catch block } if (out != null) try { out.close(); } catch (IOException e) { // TODO Auto-generated catch block } }
'안드로이드 > 개발 팁' 카테고리의 다른 글
이클립스 단축키 모음 (0) 2011.05.12 안드로이드에서 크기에 사용가능한 단위 (0) 2011.02.21 MIME Type (0) 2011.02.18 안드로이드 액티비티 생명주기 (0) 2011.02.18 외국 안드로이드 참고/커뮤니티 사이트 (1) 2011.02.17