diff --git a/src/com/upc/pbe/upcnews/VideoActivity.java b/src/com/upc/pbe/upcnews/VideoActivity.java index b999ae2..62207dc 100644 --- a/src/com/upc/pbe/upcnews/VideoActivity.java +++ b/src/com/upc/pbe/upcnews/VideoActivity.java @@ -232,12 +232,13 @@ public class VideoActivity extends Activity { try { int index = 0; - String newFileName = fileName; - while(new File(filePath + newFileName).exists()) + String newFileName = fileName.substring(0,fileName.lastIndexOf(".")); + String extension = fileName.substring(fileName.lastIndexOf(".")); + while(new File(filePath + (newFileName + extension)).exists()) { - newFileName = fileName + index++; + newFileName = fileName.substring(0,fileName.lastIndexOf(".")) + index++; } - fileName = newFileName; + fileName = newFileName + extension; FileOutputStream out = new FileOutputStream(filePath + fileName); BufferedInputStream in = new BufferedInputStream(urls[0].openStream()); Log.d(TAG, "\nDescarregant: \n");