Commit 9857dc0fe2f0cf219151433edac3f5720c49184d
1 parent
a9fb9749
Bug duplicates finally fixed
Showing
1 changed file
with
5 additions
and
4 deletions
src/com/upc/pbe/upcnews/VideoActivity.java
... | ... | @@ -232,12 +232,13 @@ public class VideoActivity extends Activity { |
232 | 232 | try |
233 | 233 | { |
234 | 234 | int index = 0; |
235 | - String newFileName = fileName; | |
236 | - while(new File(filePath + newFileName).exists()) | |
235 | + String newFileName = fileName.substring(0,fileName.lastIndexOf(".")); | |
236 | + String extension = fileName.substring(fileName.lastIndexOf(".")); | |
237 | + while(new File(filePath + (newFileName + extension)).exists()) | |
237 | 238 | { |
238 | - newFileName = fileName + index++; | |
239 | + newFileName = fileName.substring(0,fileName.lastIndexOf(".")) + index++; | |
239 | 240 | } |
240 | - fileName = newFileName; | |
241 | + fileName = newFileName + extension; | |
241 | 242 | FileOutputStream out = new FileOutputStream(filePath + fileName); |
242 | 243 | BufferedInputStream in = new BufferedInputStream(urls[0].openStream()); |
243 | 244 | Log.d(TAG, "\nDescarregant: \n"); | ... | ... |