The File control supports read, write and append operations on files using the Extensible mechanism. You set up a JCX file specifying the io-type attribute to be either read, write, or append. The supported types for the file content are: XmlObject, RawData and String. Only String and RawData types are supported for append operations.
The File control also support copy, rename and delete file operations. Typically, these operations are used to manipulate large files, without having to process them in any way. You can also generate a list of files in the specified directory.
The following are the File control methods:
/** * File Control base interface */ public interface FileControl extends Control { /** * Returns Iterator for the File objects matching the specified file mask in the * current directory. * * @return an iterator for the File objects for the files * in the current directory matching the file mask */ FileControlFileListDocument getFiles(); /** * Set the dynamic properties for the control * * @param xmlProp the dynamic properties for the control * @exception IllegalArgumentException if invalid properties are specified */ public void setProperties(FileControlPropertiesDocument xmlProp) throws IllegalArgumentException; /** * Get the dynamic properties for the control * * @return a FileControlPropertiesDocument object */ public FileControlPropertiesDocument getProperties(); /** * Rename the current file to the specified file name. * * @param fileName name of the file to be renamed to * @exception IllegalArgumentException if invalid file name is specified * @exception FileNotFoundException if the file is not present * @exception IOException reading the file * @exception SecurityException reading the file */ public void rename(String fileName) throws FileNotFoundException, java.io.IOException, SecurityException, IllegalArgumentException; /** * Delete the current file. * * @exception IllegalArgumentException if invalid file name is specified * @exception FileNotFoundException if the file is not present * @exception IOException reading the file * @exception SecurityException reading the file */ public void delete() throws FileNotFoundException, java.io.IOException, SecurityException; /** * Copy the current file to the specified file name. * * @param fileName name of the file name to be copied to * @exception IllegalArgumentException if invalid file name is specified * @exception FileNotFoundException if the file is not present * @exception IOException reading the file * @exception SecurityException reading the file */ public void copy(String fileName) throws FileNotFoundException, java.io.IOException, SecurityException, IllegalArgumentException; /** * Reset the file control by closing any in-progress operations such as: * readLine, readRecord and append. */ public void reset(); }
The following code shows an example of an extended control. This code is automatically created by the control wizard.
package jc.fileControl; import weblogic.jws.*; import com.bea.control.*; import java.io.*; import com.bea.data.RawData; import com.bea.xml.XmlObject; /** * A custom File Control. * * @jc:file directory-name="c:\some\directory" * file-mask="filetooperateon" * create-mode="over-write" */ public interface MyFileControl extends FileControl, com.bea.control.ControlExtension { /** * @jc:file-operation io-type ="read" */ XmlObject readPO(); /** * @jc:file-operation io-type ="write" */ FileControlPropertiesDocument writePO(XmlObject po); }