error: cannot find symbol ...String base64 = Base64.encodeToString(array, Base64.DEFAULT);
Base64.DEFAULT
is from Android, not the java.util.Base64
. (If you look at the docs for java.util.Base64
, you'll see it really doesn't have a DEFAULT
member - you should always be careful about contextual things like this when copying code from elsewhere.
I believe all you need to use java.util.Base64
is
String base64 = Base64.getEncoder().encodeToString(array);
Base64 apache.commons .encodeBase64 symbol not found
The new
keyword expects a type to be created. As the little caret points out, there should be brackets ()
behind Base64
.
Yet, Base64
is a collection of static
methods, so you are done if you just drop the new
in this case.
String encStr = Base64.encodeBase64String(out);
should do the trick.
Cannot Resolve Symbol "Default"
I solved this in following 2 Steps;
Add this
import android.util.Base64;
Remove these
import java.util.Base64;
import java.util.Base64.Decoder;
Base64Encoder cannot be resolved
Looks like you are using a class that does not exist in a jar you have included in the web application. Can you try the following? Make adjustments if necessary, I am just looking at the documentation for commons and typing this out --
- Go to http://commons.apache.org/codec/index.html and read through the information there
- Now go to http://commons.apache.org/codec/download_codec.cgi and download the zip file
- Extract out the jar file and copy it to the lib directory of your web application
- Replace the line
[String encoding = Base64Encoder.encode ("test:test");]
with
String encoding = new String(
org.apache.commons.codec.binary.Base64.encodeBase64
(org.apache.commons.codec.binary.StringUtils.getBytesUtf8("test:test"))
);
Related Topics
Difference Between Thread's Context Class Loader and Normal Classloader
How Are Spring Data Repositories Actually Implemented
How to Search Google Programmatically Java API
Jquery, Spring MVC @Requestbody and JSON - Making It Work Together
Java String Split with "." (Dot)
Java: Insert Multiple Rows into MySQL with Preparedstatement
How to Perform Mouseover Function in Selenium Webdriver Using Java
Webdriver - Wait for Element Using Java
Java Integer Compareto() - Why Use Comparison VS. Subtraction
What Is the Exact Meaning of Static Fields in Java
How to Resolve Java Unknownhostkey, While Using Jsch Sftp Library
Jar Bundler Using Osxadapter Causing Application to Lag or Terminate
Should a Retrieval Method Return 'Null' or Throw an Exception When It Can't Produce the Return Value
How to Tell If I'm Running in 64-Bit Jvm or 32-Bit Jvm (From Within a Program)
How to Import a .Cer Certificate into a Java Keystore
Does Use of Final Keyword in Java Improve the Performance