Monday, March 3, 2014

Base64 decoding help on the issue


Hello everyone brother for help

I use Base64 decoding a relatively large file in about 1M it

Then I practice

 FileOutputStream outStream = new FileOutputStream (localFile); 
InputStream inputStream = conn.getInputStream ();
byte [] buffer = new byte [1024];
int len ​​= 0;
byte [] decode = null;
while ((len = inputStream.read (buffer))! = -1)
{
decode = Base64.decode (buffer, 0, len, Base64.DEFAULT);
outStream.write (decode, 0, decode.length);
}
inputStream.close ();
outStream.close ();


Tip java.lang.IllegalArgumentException Runtime: bad base-64

Help What is the problem Can not Break decoding?
Only whole decoding it? (More files are large, easy to overflow ah)
Help us the
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
decode = Base64.decode (buffer, 0, len, Base64.DEFAULT);
outStream.write (decode, 0, decode.length);
No complete reading the stream, there is a problem directly decode,
IO data streams are first read and then decoded
Reply:
Haha great God is your

Why not read a solution because I want to extract some many such large files

If the entire read the words would come overflowed
Reply:
You can read a file of a file
Reply:
reference to the third floor qingqing_benniu reply:
a file to a file that you can read


I tried to read one by one to read the full stream decoding

However, when the file is too large are generally processed in the end sixty-seven documents they reported overflow. .

So I just want to be able to decode segments
Reply:
String string = Base64.encodeToString (bytes, Base64.DEFAULT);
Try it this way it

Reply:
I have to decode
Reply:
reference to the 6th floor u011389105 reply:
I have to decode
 I see're wrong You're wrong ...


Reply:
If it is a large file, you adjust the JVM heap memory,
base64 decoded stream when reading failure is if the solution does not come out.
Reply:
Thank god the big upstairs good

I try to

No comments:

Post a Comment