|Subject: calling Custom File Adapter from a server app|
Author: Minollo I.
Date: 13 Dec 2005 08:58 AM
You need to use a different createStylusFile method to do that:
public StylusFile createStylusFile(String url,
Create a StylusFile object for file access through a custom file system. This method differs from createStylusFile(String) in that it invokes a 2 argument constructor (String, InputStream) of the StylusFile class. This is useful if the StylusFile object being created is an adapter or converter which will read input from the InputStream. The application will normally get the result of the conversion by calling getInputStream() and using it to read the converted data.
If you apply that to one of the examples in demo.java, you can do a stream-to-stream operation:
File in_1 = new File(datapath + File.separator + "one.csv");
InputStream is = new FileInputStream(in_1);
StylusFile converter = sff.createStylusFile("adapter:///CSV:sep=,:first=yes", is); //note that we dropped the file from the URL
File out_1 = new File(datapath + File.separator + "one.xml");
OutputStream os = new FileOutputStream(out_1);
The "is" input stream is built against a file in this case, but it could be anything which is an InputStream really.
BTW, there is also a "createStylusFile(String url, OutputStream os)" for creating stream-to-stream of XML-to-nonXML conversions.
Hope this helps,