applekanna
asked on
Files and Streams
Question -
A method used AnyMethod(java.io.File , java.io.File ) signature
I have InputStream and string of the data in the file as I create them on the fly and there is no "file" in the server.
How do I pass the InputStream/string to the method with the above signature.
Context
I am using FOP and it uses xml and fo .
To emberd itin a servelt and convert to PDF it uses
XSLTInputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile);
where the xmlFile, xslFile are java.io.File, I have the XML and XSL as InputStreams / strings in my servers memory as they are generated dynamically, how to pass them
Thx
A method used AnyMethod(java.io.File , java.io.File ) signature
I have InputStream and string of the data in the file as I create them on the fly and there is no "file" in the server.
How do I pass the InputStream/string to the method with the above signature.
Context
I am using FOP and it uses xml and fo .
To emberd itin a servelt and convert to PDF it uses
XSLTInputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile);
where the xmlFile, xslFile are java.io.File, I have the XML and XSL as InputStreams / strings in my servers memory as they are generated dynamically, how to pass them
Thx
ASKER
FileOutputStream fos = new FileOutputStream(new File("myfile.pdf"));
1. when I do something like this , would not I run into concurrency issues in the servlet because of the file name, so to make it use I need to give each file a unique file name (say system time - any other ideas)
2. Also I need to keep deleting the files to take care of memory issues.
I am currently doing the above both
Out of curiosity
Is this the only way ...or is there any other method
1. when I do something like this , would not I run into concurrency issues in the servlet because of the file name, so to make it use I need to give each file a unique file name (say system time - any other ideas)
2. Also I need to keep deleting the files to take care of memory issues.
I am currently doing the above both
Out of curiosity
Is this the only way ...or is there any other method
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thx for ur comments
Thank you for accepting, glad I was of help :)
FileOutputStream fos = new FileOutputStream(new File("myfile.pdf"));
// get the bytes from the input stream
fos.write(<bytes>);
fos.flush();
fos.close();
Then use this file (myfile.pdf) to pass it in the method.