The StylusFile Object

In Java, we write the following to retrieve the content of a file, myfile.txt, that resides on an FTP server:

java.net.URL myUrl = new java.net.URL("ftp://myserver/myfile.txt");
               
java.io.InputStream inputstream = myUrl.openStream();
               

            

The content of myfile.txt is placed in an instance of java.net.URL called myUrl.

The StylusFile object in the Stylus Studio File System Java API is similar to java.net.URL. In Stylus Studio, you use the createStylusFile() method in the StylusFileFactory class to create an instance of a StylusFile object, the contents of which is specified by an adapter URL. Consider the following simple Java application, which uses the URL composed by Stylus Studio that was introduced in Adapter URLs.

StylusFile myStylusFile = 
StylusFileFactory.getFactory().createStylusFile("adapter:CSV:newline=crlf:
sep=,:first=yes:escape=/:quotes='\"?file:///c:/Program Files/Stylus Studio 
XML Professional Edition/examples/Adapters/three.txt");
               
 
               
java.io.InputStream inputstream = myStylusFile.getInputStream();
               

            

In this example, the InputStream object holds the conversion result supplied by the adapter URL (that is, the conversion of three.txt using the CSV adapter).

See Example - demo.bat for a description of the sample Java application installed with Stylus Studio, which illustrates different uses of the adapter URL.

 
Free Stylus Studio XML Training: