Exibindo o codigo ASCII de um texto

1 resposta
A

Ola Galera!



Alguem sabe como eu posso imprimir na tela o código ASCII de um texto contido em uma String??

Ex:



Aonde tiver quebra de linha, imprima /n… e assim por diante!



Agradeço se puderem me ajudar!

1 Resposta

E
Veja se isso te ajuda !!!








import java.lang.Character;


import java.util.*;





class ConverteAscii


{


	public static void main (String[] args)


	{


		String teste = "abcdefghij01234567"+


				    " a b c";


		


		System.out.println(" ---------- Inicio do Programa -----------");


		System.out.println("String = " + teste);


		


		char a[] = teste.toCharArray();


		


		for(int i=0; i < a.length; i++)


		{			


			int aChar = (new Integer(a[i])).intValue();


			System.out.println("Caracter: " + a[i] + " - i: " + i + " Valor ASCII: " + aChar);


		}	


		System.out.println(" ---------- Fim do Programa -----------");


	}


}
Criado 5 de junho de 2003
Ultima resposta 6 de jun. de 2003
Respostas 1
Participantes 2