개발/개발 자료
(Android) 웹에서 Text,Image 등 파일 읽어오기
시원한물냉
2014. 7. 13. 11:11
public void HttpDown(String Url, String FileName)
{
URL imageDownUrl;
int Read;
try {
imageDownUrl = new URL(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, MODE_WORLD_READABLE);
for (;;)
{
Read = is.read(raster);
if (Read <= 0)
{
break;
}
fos.write(raster,0, Read);
}
is.close();
fos.close();
} catch (Exception e) {
System.out.println("error");
return;
}
}