L'exemple de cet article indique la méthode de la chaîne d'interception Java. Partagez-le pour tout le monde pour votre référence. La méthode de mise en œuvre spécifique est la suivante:
Public static void main (String args []) {// Le premier apparaît avec ce caractère, et commence à intercepter // string str = "abc.def"; .ttttt "; // string str1 = str.substring (str.indexof (". ") +1, str.length ()); // La dernière fois que le caractère est apparu, a commencé à intercepter la chaîne str =" http: / /wxj.videocc.net/wxj/images/2014/12/i3jwci4j.jpg "; String str1 = str.substring (str.lastindexof (" / "); // 5 caractères // string str =" http: // wxj.videocc.net/wxj/images/2014/12/i3jwci4j.jpg "; // string str1 = str.substring (str.length () -5 5, str .length ()); System.out.println ( str1);}
On espère que cet article est utile à la conception du programme Java de tous.