Avoid storing as file in java

P

Petterson Mikael

Hi,


Is there a way to avoid creating a file and just keep the stream in
memory and send the stream to the transform method.
The transform() in java supports a lot of streams and I don't really see
the purpose of creating a temporary file and send the file name as
source.

All advice is greatly appreciated in this matter.

//Mikael



Here is my code:
***********************************************

public void findTitle( .....){

//if title is found then set titleFound == true

try{
OutputStream fout= new FileOutputStream("result.xml");
OutputStream bout= new BufferedOutputStream(fout);
OutputStreamWriter out = new OutputStreamWriter(bout, "8859_1");



if (titleFound == true){


//Build and write xml document.
out.write( (<?xml version=\"1.0\" "));
out.write(...);
....
out.flush();
out.close();

}

}catch(IOException ioe){
System.out.println(e.getMessage());s
}

}

In my JSP page:


//I will check if there is a file called result.xml. If it is I will
call transfrom()

transform (String pathToXml, String pathToXsl, JspWriter out){

}
 
R

Roedy Green

Is there a way to avoid creating a file and just keep the stream in
memory and send the stream to the transform method.
The transform() in java supports a lot of streams and I don't really see
the purpose of creating a temporary file and send the file name as
source.

ByteArrayStream. See http://mindprod.com/fileio.html for how to code
it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top