• Post Reply Bookmark Topic Watch Topic
  • New Topic

I need to write a char array to file  RSS feed

Ray Smilgius
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • 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 ]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!