Home >
other > Java constant string is too long
Java constant string is too long
Want to convert a base64 photo to JPG images, the character is too long, ask the how to solve?
Public static void main (String [] args) {
//string is too long, hair don't come out, all omit part of
String strImg=new String("/9j/4AAQSkZJRgABAQEAAAAAAAD/2wBDAAYEBAQFBAYFBQYJBgUGCQsIBgYICwwKCgsKCgwQDAwMDAwMEAwODxAPDgwTExQUExMcGxsbHB8fHx8fHx8fHx//2wBDAQcHBw0MDRgQEBgaFREVGh8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx//wAARCAQ4B4ADAREAAhEBAxEB/8QAHQAAAgMBAQEBAQAAAAAAAAAAAAIBAwQFBgcICf/EAFkQAAIBAwEEBQcHCQYEBAQCCwECAwAEESEFEjFBEyJRYXEGFDKBkaGxI0JScsHR8AcVM2KCkqKy4SRDU8LS8TRjc4MWVJOjCCVEs+IXNcPyZNMmRTZ0tIT/xAAaAQEBAQEBAQEAAAAAAAAAAAAAAQIDBAUG/8QAPBEBAQACAQMCBAQFAwMEAgEFAAECESEDEjFBUQRhcfATIjKBBZGxwdFCUqEUcuEjM2LxgsJDkrLyFdL/2gAMAwEAAhEDEQA/APgdw2F00r6t8vIy5NBNAtA1AUBQFAUBQFAUBQFAUBQFAVUFAUBQFAUBQFAUBQTQFAUBQFAUBQFAUBVUUBRBRRQFEFAUUUBQTRBQFAUUUQUBQFAUBQFAUBQTRUUQUBQFAUBQFAUBQTVBQTQFBFAUE1BFUFAUBQTQFAVAVQUEUE0BUBQFAUBQFAUBQFAUBQFAVQUBQFQFUFAVAVQUBQFAVAUBQFBFUFAUBQTUZLRoUBQGaAoCjIo0KAoJqhc0Ua0RFAUExxyTSCOIZY8TyAHEk8hUt0SbfQ/JLyKWKMT3EfSTSHcVJAwTeKsymbAyqdXeVfn/ADsDQ+Pq9Z6+n05HpfKLygjgjeytDjpDvXM3zpXHbjggzoo0FcOnjbzWssnjnd5GJJOvGvVJpxtOkWmfUO81R0IYQ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ecodeBuffer (strImg);
for (int i=0; I & lt; Bytes. The length; + + I) {
If (bytes [I] <0) {//adjust abnormal data
Bytes [I] +=256;
}
}
//generated jpeg images
OutputStream out=new FileOutputStream (, fileDir,);
Out. Write (bytes);
Out. The flush ();
out.close();
} the catch (IOException e) {
e.printStackTrace();
}
}