This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Modern JavaScript for the Impatient and have Cay Horstmann on-line!
See this thread for details.
Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

BASE64

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
i get the Base64 type image.i want to save it on server using jsp.
to convert this in ordinary graphics file which classes can i use for encoding and decoding.
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
base-64 is not an image type - it's an encoding used to convert binary content into ASCII. The Apache Commons Codec library has routines for en- and decoding base-64.
 
Ratan Pawar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How i can save this base64 string as a image.
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where you successful running the base-64 decoder? Is the result a valid image file?
 
Ratan Pawar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes,decoding is successful.
now i want to save it as image file.what should i use for it.
i tried imageio but how pass correct parameter or what other things for saving it as image.
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What did the base-64 decoder hand back to you - a byte array? If so, you can use a FileOutputStream to write the bytes to a file.
 
Ratan Pawar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes its working.
Thank you very much Sir.
 
Ratan Pawar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir,Now i can show this saved images to the client.
I used FileInputReader for read the file.
and then encode it.is required to encode now?
Because now we want to show only that saved image.
when i put it ac image it not show the image.
i also used ListFiles to read the names of file in folder.
it is successful but it not shows as a image.
what to do?
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I used FileInputReader for read the file. and then encode it.is required to encode now?


An encoded image can't be displayed, so, no, encoding is not only not required, it is harmful, because it prevents the image from being used elsewhere.

i also used ListFiles to read the names of file in folder.
it is successful but it not shows as a image.


What is "it"? A web page? An AWT/Swing component? Is this still a version of the image that is encoded? I thought you said you were successful decoding it.
 
Ratan Pawar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir,i want do display image in web page.
I did it successfully.I read the saved file name from the directory
and then it filename give as source for the image.its working.
No need of Decoding.
if i want to write it on canvas then i think decoding is required.
Thank you Sir.
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

if i want to write it on canvas then i think decoding is required.


Once you decode the image and store it, it is no -obviously- no longer encoded. It has to be, because it couldn't be displayed otherwise. So I don;t understand why you think another decoding step might be necessary.
    Bookmark Topic Watch Topic
  • New Topic