Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

delete ending part of the string java

//To delete starting from "opened"
String str ="13 opened by someone";

String result = str.substring(0,str.lastIndexOf(" opened"));
Comment

Delete end element in string java

public String method(String str) {
    if (str != null && str.length() > 0 && str.charAt(str.length() - 1) == 'x') {
        str = str.substring(0, str.length() - 1);
    }
    return str;
}
Comment

PREVIOUS NEXT
Code Example
Java :: java copy file 
Java :: setting scale to big decimal java 
Java :: java for increment by 2 
Java :: string length in java 
Java :: split number java 
Java :: how to remove duplicate elements from char array in java 
Java :: queue implementation in java using arraylist 
Java :: how to make java list 
Java :: java how to convert string to int 
Java :: java string regexp replace 
Java :: How to efficiently shift a linked list by k positions, in Java? 
Java :: copy constructor in java 
Java :: last char in string java 
Java :: check how many times a character appears in a string java 
Java :: java create empty arraylist 
Java :: Java Creating a Vector 
Java :: hashmap to list java 
Java :: How to convert long to string android studio - java 
Java :: passing array by reference java 
Java :: Java How to use Set? 
Java :: matrix multiplication javascrpt 
Java :: java files 
Java :: BST in java 
Java :: java for loop increment by 3 
Java :: java wait for user input 
Java :: java constructor overloading 
Java :: mockito verify more than once 
Java :: indext of minimum element in an array in java 
Java :: Java Sorting Using sort() 
Java :: java bufferedreader read all lines 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =