How can I check if at the end of a string it is 0
?
The problem with this code is that string can contain:
jrp_documento.jrp_doc_001provider | 0
I need to check if the end of the string is 1
or 0
.
I have identified another problem as well. Since this string is the name of the table in the database it is necessary to be the same as the table, I give replaceAll
there in 0
if it contains 0
, but if string contains% as_% it exits and is not to be removed unless 0
is at the end. What do I do?
public static void main(String[] args) {
String nomeColuna = null;
String coluna = null;
String sampleString = "jrp_documento.jrp_doc_fornecedor|0";
String[] items = sampleString.split(";");
List<String> itemList = Arrays.asList(items);
for(int i = 0; i < itemList.size(); i++){
coluna = items[i].replaceAll("[|]", "");
coluna = coluna.replaceAll("[.]", "_");
if(coluna.contains("0")){
nomeColuna = coluna.replaceAll("0", "");
System.out.println(nomeColuna);
System.out.println(" é zero ");
}else{
nomeColuna = coluna.replaceAll("1", "");
System.out.println(nomeColuna);
System.out.println(" é um ");
}
}