• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

I need to write a char array to file

Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a function called decode(sPDFImage);
Here is part of the function:
<%! public static char[] decode(String text) {
return decode(text.toCharArray());
The sPDFImage is the actual pdf base64 which needs to be converted to binary.
Basically, I have the pdf displaying properly in the browser but now I need to write the PDF to a file. I have the code doing this, but it won't open because it is not properly decoded.
This call:
out.flush(); //added flush to ensure buffer is flushed for subsquent requests
This works when it opens in the browser but I need to write it to a file then open it.
Here is my code which I am using:
DataOutputStream output_stream;
output_stream = new DataOutputStream(new FileOutputStream("c:\\" + sSessionID + ".pdf"));
char[] ray = new char[decode(sPDFImage).length];
int x = 0;
ray = decode(sPDFImage); //put the return array into ray[]
for(x = 0; x < ray.length; ++x){
My machine starts beeping when I run this code
I do get stuff in the file but it is garbage, I need what is displayed in the browser as a PDF.
Anyways is there another way I can get the char array written to a pdf file that I can open?
Thanks Ray
[ December 03, 2002: Message edited by: Ray Smilgius ]
[ December 04, 2002: Message edited by: Ray Smilgius ]
    Bookmark Topic Watch Topic
  • New Topic