I have made this small script to test something, but I can't get it working. I want it to replace the "%20" in the string to " ". This gets printed out: Ravenous%20Cache.zip
package test;
public class Test {
public static void main(String[] args) {
System.out.println(getArchivedName());
}
private static String cacheLink = "https://dl.dropboxusercontent.com/u/Ravenous%20Cache.zip";
private static String getCacheLink() {
return cacheLink;
}
private static String getArchivedName() {
String name = cacheLink.replace("%20", " ");
int lastSlashIndex = name.lastIndexOf('/');
if (lastSlashIndex >= 0
&& lastSlashIndex < getCacheLink().length() -1) {
return getCacheLink().substring(lastSlashIndex + 1);
} else {
System.err.println("Error Downloading Game Files.");
}
return "";
}
}
getCacheLink()instead of a substring ofname.