Pegar Somente numeros Em JformattedTextfild. (RESOLVIDO)

Bom Dia! Preciso pegar somente os numeros que estão em um JformattedTextfield com Mascara de Cep.
Como Fazer?

Abraços… :smiley:

vc pode percorrer td a string e retirar os caracteres assim:

[code]String teste = “032.777.654-25”;
String saida = “”;

	for (int i = 0; i < teste.length(); i++) {
		switch (teste.charAt(i)) {
		case '.':
			saida += "";
		case '-':
			saida += "";
			break;
		default:
			saida += teste.charAt(i);
			break;

		}
	}

	System.out.println(saida);

[/code]

Obrigado por Responder! :smiley:

Esse metodo pensei em fazer msm, Criei o Topico pra saber saber se tinha um Comando especifico qnd existe mascara!

Mais Esse Resolve… Se alguem Souber algo melhor post ai!

Abraços

vc poderia usar tbm o replaceAll

 replaceAll(".","")

e substituir o ponto por “” nao testei.
flw

falei no replaceAll, pesquisei e achei isso aqui

flw

Esse Ultimo ai é muito Bom!!! Satisfeito!! Muito Obrigado…

public static String onlyNumbers(String str) {
   if (str != null) {
      return str.replaceAll("[^0123456789]", "");
   } else {
      return "";
   }
}