Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // try{
- try {
- File cacheDir = new File(
- android.os.Environment.getExternalStorageDirectory(),
- "Folder Name");
- if (!cacheDir.exists())
- cacheDir.mkdirs();
- File f = new File(cacheDir, "songname" + ".mp3");
- URL url = new URL(
- "http://210.211.99.70/teenpro.vn/files/song/zg/zg_Co-Khi-Nao-Roi-Xa-Bich-Phuong.mp3");
- InputStream input = new BufferedInputStream(url.openStream());
- OutputStream output = new FileOutputStream(f);
- byte data[] = new byte[1024];
- long total = 0;
- int count = 0;
- while ((count = input.read(data)) != -1) {
- total++;
- Log.e("while", "A" + total);
- output.write(data, 0, count);
- }
- output.flush();
- output.close();
- input.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
Add Comment
Please, Sign In to add comment