Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

java - Base64 Encoding: Illegal base64 character 3c

I am trying to decode data in an xml format into bytes base64 and I am having an issues. My method is in java which takes a String data and converts it into bytes like as bellow.

String data = "......"; //string of data in xml format
byte[] dataBytes = Base64.getDecoder().decode(data);

Which failed and gave the exception like bellow.

java.lang.IllegalArgumentException: Illegal base64 character 3c
    at java.util.Base64$Decoder.decode0(Base64.java:714)
    at java.util.Base64$Decoder.decode(Base64.java:526)
    at java.util.Base64$Decoder.decode(Base64.java:549)
    at XmlReader.main(XmlReader.java:61)

Is the xml format not compatible with base64?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just use this method

getMimeDecoder()

String data = "......";
byte[] dataBytes =  Base64.getMimeDecoder().decode(data);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...