As you can see in the code below, I want to check if a string has a ? in his name. If yes, I remove it. My problem is that the variable 'nameOfFileOnlyCleaned' stay local and is empty after the if else. Thank you for your help.
String nameOfFile = list_attachments_Of_Reference[j].toString().split('/').last;
if (nameOfFile.contains('?')) { //Removes everything after first '?'
String nameOfFileOnlyCleaned = nameOfFile.substring(0, nameOfFile.indexOf('?'));
} else{
String nameOfFileOnlyCleaned = nameOfFile;
}
//Here my variable 'nameOfFileOnlyCleaned' is empty.
This is a problem because the value should be used later
in the code. Do you know why I have this issue please?
Many thanks.
String extensionFile = nameOfFileOnlyCleaned.split('.').last;
String url_Of_File = list_attachments_Of_Reference[j].toString();
Aucun commentaire:
Enregistrer un commentaire