Hex para ASCII

1 resposta
A

[size=18] Hex para ASCII – Básico[/size]

public static String HexaParaString(String textoInicial){
		
		StringBuilder textoFinal = new StringBuilder();
		
		for(int i = 0; i < textoInicial.length(); i += 2){
			
			String saida = textoInicial.substring(i, (i + 2));
    		int decimal = Integer.parseInt(saida, 16);
    		
    		textoFinal.append((char)decimal);		
		  }
    	   
    	return textoFinal.toString();    	 
	 }
public static void main(String[] args) {	
		
		String hex = "687474703a2f2f7777772e796f75747562652e63" +
				     "6f6d2f77617463683f763d6a70534e49456a596c" +
				     "477726666561747572653d72656c61746564";		
			
		System.out.printf(HexaParaString(hex));				
	}

1 Resposta

lina

Oi,

Eu consistiria se a String passada é Hexadecimal (0 - 9, A - F (a - f)).

Tchauzin!

Criado 3 de maio de 2012
Ultima resposta 4 de mai. de 2012
Respostas 1
Participantes 2