aboulfazl950
چهارشنبه 29 آذر 1391, 10:04 صبح
سلام!کسی میدونه چطور باید فایل باینری را دانلود کرد
می خواهم یک url بدهم و برنامه آن را در یک آدرس معین مثلا درایوc ذخیره کند.
(url ادرس یک عکس یا فیلم یا هرچیزی به غیر از آدرس صفحه خواهد بود)
spiderman200700
پنج شنبه 30 آذر 1391, 16:10 عصر
public void saveUrl(String filename, String urlString) throws MalformedURLException, IOException
{
BufferedInputStream in = null;
FileOutputStream fout = null;
try
{
in = new BufferedInputStream(new URL(urlString).openStream());
fout = new FileOutputStream(filename);
byte data[] = new byte[1024];
int count;
while ((count = in.read(data, 0, 1024)) != -1)
{
fout.write(data, 0, count);
}
}
finally
{
if (in != null)
in.close();
if (fout != null)
fout.close();
}
}
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.