سلام
در این برنامه یک فایلی از اینترنت دان و در sd کارد گوشی ذخیره میشود
چرا ما در هنگام خواندن فایل 10 کیلوبایت 10 کیلوبایت میخوانیم و موقع نوشتن 1 کیلو بایت 1کیلوبایت نوشته مشود. چرا از بافر استفاده میشود؟
 @Override
protected String doInBackground(String... params) {
try {
URL url=new URL("http://s8.picofile.com/d/8349389850/06c69ac4-70fb-4d33-991f-ac01b8c5324f/b.mp3");
URLConnection connection=url.openConnection();
connection.connect();


InputStream fis=new BufferedInputStream(url.openStream(),10*1024);
FileOutputStream fos=new FileOutputStream(Environment.getExternalStorageDir ectory().getPath()+"/saeed.mp3");


int c=0;
byte[] d=new byte[1024];
while ((c=fis.read(d))!=-1)
{
fos.write(d,0,c);
}


fos.flush();
fos.close();
fis.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}