Question

Je veux retirer la barre oblique de fuite d'une chaîne en Java.

Je veux vérifier si la chaîne se termine par une URL, et si c'est le cas, je veux le supprimer.

Voici ce que j'ai:

String s = "http://almaden.ibm.com/";

s= s.replaceAll("/","");

et ça:

String s = "http://almaden.ibm.com/";
length  =  s.length();
--length;
Char buff = s.charAt((length);
if(buff == '/')
{
     LOGGER.info("ends with trailing slash");
/*how to remove?*/
}
else  LOGGER.info("Doesnt end with trailing slash");

Mais ni un travail.

Pas de solution correcte

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top