2012-09-12 3 views
0

jdk 1.6 대신 jdk 1.4에서 응용 프로그램을 컴파일하는 데 문제가 있습니다.바이트에서 16 진수로 포맷터 기호를 찾을 수 없음

해결하기 위해 좀 솔루션을 제공하십시오 ... 코드 위

String encryptedString = null; 
      byte[] bytesToBeEncrypted; 
      try { 
       // convert string to bytes using a encoding scheme 
       bytesToBeEncrypted = ren_pass.getBytes("UTF-8"); 
       MessageDigest md = MessageDigest.getInstance("MD5"); 
       byte[] theDigest = md.digest(bytesToBeEncrypted); 
       // convert each byte to a hexadecimal digit 
       Formatter formatter = new Formatter(); 

       for (int i = 0; i <= theDigest.length; i++) { 
        byte b = theDigest[i];       
        //for (byte b : theDigest) { 

    formatter.format("%02x", b); // error on this statement b cannot find symbol      
       } 
       encryptedString = formatter.toString().toLowerCase(); 
       System.out.print(encryptedString); 

      } catch (UnsupportedEncodingException eq) { 
       eq.printStackTrace(); 
      } catch (NoSuchAlgorithmException ew) { 
       ew.printStackTrace(); 
      } 

는 JDK 1.6에서 잘 작동하지만 발견되지 b를하지 JDK 1.4 ...에

이 오류 기호가 표시 그것 ...

답변

0

jdk1.4에는 java.util.Formatter가 없습니다. java.util.logging.Formatter로 코드를 컴파일 했습니까?

대신에 Character.forDigit (byteValue, 16)을 사용하십시오.