9

I want to use DataTypeConverter.printBase64Binary(.........) in my project. But there is no option coming through intellisense. Am i missing some jar ?

Mufrah
  • 534
  • 7
  • 22
  • have you imported javax.xml.bind.DatatypeConverter? if this is not an issue try Window -> Preferences -> Java/Editor/Content Assist and select your likings – Ashwani Oct 16 '12 at 09:29
  • I tried to import import javax.xml.bind.DataTypeConverter; .But a error is prompting "Create class DataTypeConverter class". – Mufrah Oct 16 '12 at 10:15
  • i tried to add jaxb-api-2.2.jar .when i compiled my project i get this error
    [2012-10-16 15:48:07 - DistimoApp] Dx trouble processing "javax/xml/bind/Binder.class": Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library. This is often due to inadvertently including a core library file in your application's project, when using an IDE (such as Eclipse). If you are sure you're not intentionally defining a core class, then this is the most likely explanation of what's going on.
    – Mufrah Oct 16 '12 at 10:49
  • its working .i follow this article ...awesome [Add a third party jar in android and make it delvik converted jar ](http://stackoverflow.com/questions/3642928/adding-a-library-jar-to-an-eclipse-android-project) – Mufrah Oct 16 '12 at 11:41

2 Answers2

4

you can use this methods. compile 'commons-codec:commons-codec:1.3'

and i use android.util.Base64 for Android

incompatible / replacement

DatatypeConverter.parseHexBinary 
org.apache.commons.codec.binary.Hex.decodeHex(key.toCharArray());




DatatypeConverter.printBase64Binary(finalData);
android.util.Base64.encodeToString(finalData, 16) 



DatatypeConverter.parseBase64Binary(encodedInitialData);
org.apache.commons.codec.binary.Hex.decodeHex(key.toCharArray());

Question

Community
  • 1
  • 1
David Hackro
  • 3,652
  • 6
  • 41
  • 61
2

Android API provides Base64 to do the conversions you are looking for. However, I used Apache Codec as a compatibility library between different platforms for the client library to get around this issue.

Archimedes Trajano
  • 35,625
  • 19
  • 175
  • 265