Life is easy because we write the source code.....
Life is easy because we write the source code.....
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Why do you want to do this? Is it because your file is too big to fit into memory?
Life is easy because we write the source code.....
Pramod P Deore wrote:
Thanks James.
Why do you want to do this? Is it because your file is too big to fit into memory?
Yes, But how to do that?
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Life is easy because we write the source code.....
Pramod P Deore wrote:But I can't get it.
And actually I want to develop this application for mobile and in mobile there is no much memory available like desktop.
> So I am thinking that read some part of image encode it and save in text file after that read another chunk of bytes and encode them.
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Life is easy because we write the source code.....
Pramod P Deore wrote:I really don't get how to use it.
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Life is easy because we write the source code.....
vikas mhatre wrote:Hi, also want to this but can't succeed anybody please help me.
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Larger data are better handled with streams. The next sample code encodes a file to another, using java.io.InputStream and java.io.OutputStream objects:
InputStream inputStream = new FileInputStream("source.jpg");
OutputStream outputStream = new FileOutputStream("encoded.b64");
Base64.encode(inputStream, outputStream);
outputStream.close();
inputStream.close();
vikas mhatre wrote:
Now I had modified earlier code as
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
vikas mhatre wrote:Then what is wrong there? will you please explain me?
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
2) Allocate a byte[] as intermediate buffer. Start with it being fairly small (say 1024 bytes) and later once you have it working experiment to see what size gives you an acceptable performance.
3) Loop reading into the buffer from your InputStream and writing immediately to the Base64OutputStream. Make sure you only write the number of byes actually read. Look at the Javadoc for InputStream.read(byte[] ) to understand this.
Read this: Patience Is A Virtue.vikas mhatre wrote:Hello James are you there?
vikas mhatre wrote:Hello James are you there?
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
1) Wrap a FileOutputStream (or some other OutputStream) with a Base64OutputStream.
2) Allocate a byte[] as intermediate buffer. Start with it being fairly small (say 1024 bytes) and later once you have it working experiment to see what size gives you an acceptable performance.
3) Loop reading into the buffer from your InputStream and writing immediately to the Base64OutputStream. Make sure you only write the number of byes actually read. Look at the Javadoc for InputStream.read(byte[] ) to understand this.
4) When you have read and written all the content of the InputStream, close the Base64OutputStream.
vikas mhatre wrote:[
I don't get the 3rd point.
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
vikas mhatre wrote:Hi James Now look I have Base64 class
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
IN A LOOP YOU NEED TO READ FROM THE InputStream AND THEN WRITE WHAT HAS BEEN READ TO THE Base64OutputStream UNTIL YOU REACH THE END OF THE InputStream.
vikas mhatre wrote:
IN A LOOP YOU NEED TO READ FROM THE InputStream AND THEN WRITE WHAT HAS BEEN READ TO THE Base64OutputStream UNTIL YOU REACH THE END OF THE InputStream.
I had read and write but I am not able to apply the loop[code]
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Just to be sure: tt.jpg is smaller than 1024 byte, yes?
Censorship is the younger of two shameful sisters, the older one bears the name inquisition.
-- Johann Nepomuk Nestroy
Peter Taucher wrote:
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Censorship is the younger of two shameful sisters, the older one bears the name inquisition.
-- Johann Nepomuk Nestroy
So I left, I came home, and I ate some pie. And then I read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|