Skip to content

Instantly share code, notes, and snippets.

@loiane
Last active December 12, 2016 14:08
Show Gist options
  • Save loiane/4ac11a49e1d64d5dfbcafb5d7f2e1b3e to your computer and use it in GitHub Desktop.
Save loiane/4ac11a49e1d64d5dfbcafb5d7f2e1b3e to your computer and use it in GitHub Desktop.
public class TesteStringInteger {
public static void main(String[] args) {
String numeroDoArquivo = "99 ";
//numeroDoArquivo = numeroDoArquivo.trim(); //remove espaços das extremidades
numeroDoArquivo = numeroDoArquivo.replaceAll(" ", ""); //remove todos os espaços
long numero = Long.parseLong(numeroDoArquivo);
System.out.println(numero);
String[] dados = {"abc", "def", "99 "};
numero = Long.parseLong(dados[2].replaceAll(" ", ""));
System.out.println(numero);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment