I have the following string
http://store.aqa.org.uk/qual/newgcse/pdf/AQA-4695-W-SP.PDF
I want it so if the user forgets to input the http:// or the .PDF, the program will automatically correct this. Therefore, I tried this code
if (!str.startsWith("http://")) { // correct forgetting to add 'http://'
str = "http://" + str;
}
System.out.println(str);
if (!str.endsWith("\\Q.PDF\\E")) {
str = str + "\\Q.pdf\\E";
}
However, even when I enter the correct string, http://store.aqa.org.uk/qual/newgcse/pdf/AQA-4695-W-SP.PDF
the output is this.
http://store.aqa.org.uk/qual/newgcse/pdf/AQA-4695-W-SP.PDF\Q.pdf\E
Why? Why is another '.PDF' being added?