public String convertirascii(String cadena,int i)
    {   
    	String cadenaenascii="";
    	int tipo=0;
    	Pattern hexa = Pattern.compile("[$][A-F|0-9]+");
		 Pattern dec = Pattern.compile("[0-9]+");
		 Pattern  oct= Pattern.compile("[@][0-9]+");
		 Pattern bin = Pattern.compile("[%][0-1]+");
		 Matcher hex=hexa.matcher(cadena);
		 Matcher de=dec.matcher(cadena);
		 Matcher oc=oct.matcher(cadena);
		 Matcher bi=bin.matcher(cadena);
		 if(hex.matches())
		 {
			  tipo=16;
		 }
		 else if(de.matches())
			 tipo=10;
		 else if(oc.matches())
			 tipo=8;
		 else if(bi.matches())
			 tipo=2;
    	if(tipo==2)
    	  return Integer.toHexString(Integer.parseInt(cadena,2));
    	else if(tipo==8)
    	  return Integer.toHexString(Integer.parseInt(cadena,8));
    	else if(tipo==10)
          return Integer.toHexString(Integer.parseInt(cadena,10));
    	else if(tipo==16)
        	return Integer.toHexString(Integer.parseInt(cadena,16));
    	else 
    	    for (int x=0;x<cadena.length();x++)
    	    {
    	    	cadenaenascii+=Integer.toHexString(cadena.codePointAt(x));
    	    	
    	    }
    	    	return cadenaenascii;
    }